8

What is the easiest way to remove the "Generator" meta tag in Drupal 8?

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

Can this just be done in a few lines of code?

13

For anyone else looking (from drupal.org/node/2676164):

/**
 * 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.