10

How can I remove the Generator meta-tag in Drupal 8?

<meta name="Generator" content="Drupal 8 (https://www.drupal.org)" />

Can this be done with few lines of code?

0
16

Basing on the patch provided in Remove Generator META tag & X-Generator for Drupal 8 version! this is the code that would achieve that.

/**
 * Implements hook_page_attachments_alter().
 */
function HOOK_page_attachments_alter(array &$attachments) {
  foreach ($attachments['#attached']['html_head'] as $key => $attachment) {
    if ($attachment[1] == 'system_meta_generator') {
      unset($attachments['#attached']['html_head'][$key]);
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.