Skip to content

Instantly share code, notes, and snippets.

@DanielVeza
Created August 1, 2019 02:09
Show Gist options
  • Save DanielVeza/e07a8f3d5bef8b4ca0a1aaa0daba2235 to your computer and use it in GitHub Desktop.
Save DanielVeza/e07a8f3d5bef8b4ca0a1aaa0daba2235 to your computer and use it in GitHub Desktop.
Remove the Drupal 8 generator meta tag
/**
* Implements hook_page_attachments_alter().
*
* Removes the "Generator" tag from the <head>.
* This needs to be in the theme despite it being a hook.
*/
function themename_page_attachments_alter(array &$page) {
$html_head =& $page['#attached']['html_head'];
// Get the index for the "Generator" tag.
$system_meta_generator_index = array_search('system_meta_generator', array_column($html_head, 1));
unset($html_head[$system_meta_generator_index]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment