Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
The Generator meta tag in output shows the CMS software and version used to generate the page.
<meta name="Generator" content="Drupal 7 (http://drupal.org)" />
Some sites choose to remove or replace this from output. When considering doing so, note Hide, obscure, or remove clues that a site runs on Drupal.
Module-based solutions
Drupal generator meta tag can be hidden using the following modules:
- Remove HTTP Headers will remove the "Generator" meta tag when it is configured to remove Drupal's
X-Generator
HTTP header. - Remove Generator will remove the "Generator" meta tag specifically.
- If you use the popular Metatag module, then you can edit the Drupal generator meta tag using that module (screenshots: 1, 2, 3).
Removing or replacing Generator using templates (Drupal 7)
The same can also be done using template.php. Put in the below code in template.php file. If you already have _html_head_alter() defined, add the below code in that function.
To replace the Generator meta tag
/**
* Implements hook_html_head_alter().
*/
function YOUR_THEME_html_head_alter(&$head_elements) {
// Replace Drupal generator meta tag.
// Use this if you want to replace the Drupal 7 Generator meta tag.
$generator = 'Enter your text here';
$head_elements['system_meta_generator']['#attributes']['content'] = $generator;
if (isset($head_elements['system_meta_generator']['#attached']['drupal_add_http_header'][0][1])) {
$head_elements['system_meta_generator']['#attached']['drupal_add_http_header'][0][1] = $generator;
}
}
To remove the Generator meta tag
/**
* Implements hook_html_head_alter().
*/
function YOUR_THEME_html_head_alter(&$head_elements) {
// Remove Drupal generator meta tag.
// Use this if you want to remove the Drupal 7 Generator meta tag.
if (isset($head_elements['system_meta_generator'])) {
unset($head_elements['system_meta_generator']);
}
}
Attachment | Size |
---|---|
Step1-Metatag global.jpg | 82.96 KB |
Step2-Advanced Tags.jpg | 53.51 KB |
Step3-D7Generator.jpg | 50.69 KB |