Drupal 7: Adding Meta tags with example

The Meta tags will hold the information about the pages. We can programmatically able to add meta tags into Drupal pages. The function "drupal_add_html_head()" help to add meta tags. Below syntax and example show how to use this function.

<u><strong>Syntax:</strong></u>
$metaTag = array(
  '#type' => 'html_tag',
  '#tag' => TAG-TYPE,
  '#attributes' => array(
    'content' => CONTENT,
    'name' => META_NAME,
  ),
);
drupal_add_html_head($metaTag, UNIQUE_CODE);

Example: 

$metaTag = array(
  '#type' => 'html_tag',
  '#tag' => 'meta',
  '#attributes' => array(
    'content' =>  'no-referrer',
    'name' => 'referrer',
  ),
);
drupal_add_html_head($metaTag, 'meta_referal_tag');
Category: