How do I add a meta tag in inside the  tag? How can I add the following meta tag inside the &lt;head&gt; tag?
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot; /&gt;

I am trying to add it to a Drupal 8 site.
From different sources I found different way of adding meta tags in Drupal 8, hence compiling all ways.



1. Using THEME.theme file

I think same question has been asked on stakeoverflow: add meta tag to head in drupal 8
 and if you see the answer of @Danielishko, He has provided the following code,

Just add following code in your THEME.theme file, clear cache and you will be good to go. Note: function theme_preprocess_html(&amp;$variables) {...} should be already there in your .theme file, hence do not create new one, otherwise it will give error.

function theme_preprocess_html(&amp;$variables) {

  $xuacompatible = [
    '#tag' =&gt; 'meta',
    '#attributes' =&gt; [
      'http-equiv' =&gt; 'x-ua-compatible',
      'content' =&gt; 'ie=edge',
    ],
  ];


  $variables['page']['#attached']['html_head'][] = [$xuacompatible, 'x-ua-compatible'];
}


Output image:





2. Through Template file:

Another Question was asked on this topic: How to set / remove drupal 8 meta tags.

If you read the question in the above mentioned link, Questioner has mentioned that using html.html.twig template file you can directly add meta tags to &lt;head&gt;....&lt;/head&gt;

html.html.twig file you can find at core/modules/sytem/templates/html.html.twig, You can copy and paste that in your theme's template folder and your theme will use that one.

from html.html.twig

&lt;!DOCTYPE html&gt;
&lt;html{{ html_attributes }}&gt;
  &lt;head&gt;
    &lt;head-placeholder token="{{ placeholder_token|raw }}"&gt;
    &lt;title&gt;{{ head_title|safe_join(' | ') }}&lt;/title&gt;
    &lt;css-placeholder token="{{ placeholder_token|raw }}"&gt;
    &lt;js-placeholder token="{{ placeholder_token|raw }}"&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt;
  &lt;/head&gt;
  &lt;body{{ attributes }}&gt;
    {#
      Keyboard navigation/accessibility link to main content section in
      page.html.twig.
    #}
    &lt;a href="#main-content" class="visually-hidden focusable"&gt;
      {{ 'Skip to main content'|t }}
    &lt;/a&gt;
    {{ page_top }}
    {{ page }}
    {{ page_bottom }}
    &lt;js-bottom-placeholder token="{{ placeholder_token|raw }}"&gt;
  &lt;/body&gt;
&lt;/html&gt;


Output Image:



NOTE: This is my own logic and tried to find reference for this, I did not find any reference regarding this except one line provides by Questioner in above link, but since we edit template file for adding other stuff why we can not use to add  tags. PLEASE PROVIDE COMMENTS IF THIS IS NOT  A RIGHT WAY TO DO, It will also be learning experience for me, Thanks.



3. Create your own Custom Module

If you refer this tutorial of: Adding new HTML tags in the  in Drupal 8, He has described the general way of adding tag to head in Drupal 8. I have modified as per your requirement. You can refer this tutorial: Drupal 8: Create a Simple Module for how to develop simple module in Drupal 8, and following code will go in your module_name.module file, that's it.

for module_name.module file,

&lt;?php
/**
 * Implements hook_page_attachments().
 */
function module_name_page_attachments(array &amp;$page) {
  $xuacompatible = [
        '#tag' =&gt; 'meta',
        '#attributes' =&gt; [
          'http-equiv' =&gt; 'x-ua-compatible',
          'content' =&gt; 'ie=edge',
        ],
      ];
  $page['#attached']['html_head'][] = [$xuacompatible, 'x-ua-compatible'];
}


I think, this method and method described in 1st option are quite same.



4. Using Drupal module

I am not sure, how to use this approach, I tried to find. Here I am mentioning because when point of adding meta tags comes this module always pop-up.

I think this approach you should use. In the accepted answer he has describe the module way and you can use, Metatag module for that. This module has dependent modules Token &amp; Ctools, which is very common thing. In that answer whole procedure has been described, so I am not mentioning here.