How do I add a specific meta-tag to all the pages of a site? I want to prevent Google from indexing my website. I know I need this meta tag added to the header. 

&lt;meta name="robots" content="noindex" /&gt;


How can I add this meta-tag to all the pages of a site?
You can use the Metatag module for this, in order to add meta tags to every page of your site:



If you want to do it by coding, it is possible to implement the theme_preprocess_html hook to add the meta tag manually:

function theme_preprocess_html(&amp;$variables)
{

    $noindex = [
            '#tag' =&gt; 'meta',
            '#attributes' =&gt; [
                'name' =&gt; 'robots',
                'content' =&gt; 'noindex',
            ],
        ];
    $variables['page']['#attached']['html_head'][] = [$noindex, 'noindex'];
}


(more details here: https://stackoverflow.com/questions/35913739/add-meta-tag-to-head-in-drupal-8)