Add meta tag to <head>

Viewed 15245

I want to add meta tags to my site.

I added this code in my THEME.theme file and cleared the cache.

/**
 * Implements hook_page_attachments_alter().
 *
 * Include meta tags and fonts using attachment method.
 */
function bartik_page_attachments_alter(array &$page) {
  $font_attributes = array(
    'rel' => 'stylesheet',
    'type' => 'text/css',
    'href' => 'https://fonts.googleapis.com/css?family=Lato:400,100,100italic,300,300italic,400italic,700',
  );

  $page['#attached']['html_head_link'][] = array($font_attributes);

  $rendering_meta = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'SKYPE_TOOLBAR',
      'content' => 'SKYPE_TOOLBAR_PARSER_COMPATIBLE',
    ),
  );

  $page['#attached']['html_head'][] = [$rendering_meta, 'rendering_meta'];
}

This code just attaches the meta tag to the login page.

What should I do to add the meta tag to all the site pages?

4 Answers
Related