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?
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]);
}
}
}