Remove the Drupal 8 Generator Meta Tag

Apart from removing the generator meta tag in Drupal 8, tags such as MobileOptimized and HandheldFriendly are not needed either:

 

function THEME_NAME_page_attachments_alter(&$page){
    $meta_tags = array('system_meta_generator', 'MobileOptimized', 'HandheldFriendly');
    foreach ($page['#attached']['html_head'] as $key => $value) {
        if (in_array($value[1], $meta_tags)) {
            unset($page['#attached']['html_head'][$key]);
        }
    }
}

 

In Drupal 8, the meta generator is system_meta_generator

 

 

Got any Drupal 8 tips or something you want us to write about! Let us know in the comments!

2 thoughts on “Remove the Drupal 8 Generator Meta Tag

Leave a Reply

Your email address will not be published. Required fields are marked *