I'm trying to disable Generator meta tag and Shortlink URL definition. They were set to an empty string in admin/config/search/metatags/config page but they still appear inside the page as:

<meta name="Generator" content="Drupal 7 (http://drupal.org)" />
<link rel="shortlink" href="/node/8" />

What should I configure to get rid of them or overrride?

#25 metatag-delete-metatag-1304038-20.patch827 bytesmortenthorpe
#19 metatag-n1304038-19.patch967 bytesDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View
#16 metatag-delete-metatag-1304038-16.patch639 bytesyingtho
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View
#15 metatag-delete-metatag-1304038-15.patch1.3 KByingtho
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


Fleshgrinder’s picture

I'm using the following function within my template.php file.

 * Used to remove certain elements from the $head output within html.tpl.php
 * @see httx://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_html_head_alter/7
 * @param array $head_elements
function fftm_html_head_alter(&$head_elements) {
	$remove = array(

	foreach ($remove as $key) {
		if (isset($head_elements[$key])) {

	// Use this loop to find out which keys are available.
	/* -- Delete this line to execute this loop
	echo '<pre>';
	foreach ($head_elements as $key => $element) {
		echo $key ."\n";
	echo '</pre>';
	// */

But it's not removing the canonical and shortlink from posts because they aren't using the proper function to insert them there. I'm investigating further in this issue.

not_active_999’s picture

Most of what I have found has been overly complex and adds unneeded code to strip elements. Here is a very simple way to remove the generator and shortlink meta tags. I would not suggest removing the canonical meta as this is becoming more and more important with Google. You can always just set the canonical to the actual URL with a token in the Meta Tags module UI.

No need to hack the core or add lots of arrays, just copy and past the below and add it to template.php and you are all set.

Remember to flush your cache and reload your page.

 * Unset meta variable in the header that are part of the core.
function THEME_NAME_html_head_alter(&$head_elements) {
foreach ($head_elements as $key => $element) {
if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'shortlink') {


I am not real sure why Drupal or the Meta Tags module finds these two meta pieces to be of any value from an SEO perspective.

I know it is only 2 lines and text, but still bloated code is annoying!


Dave Reid’s picture

Title: Can't override or disable Shortlink URL and Generator » Need to be disable meta tags provided by core (generator, shortcut icon, shortlink)
Version: 7.x-1.0-alpha3 »
Assigned: Unassigned » Dave Reid

With http://drupalcode.org/project/metatag.git/commit/76a380d it is now possible to completely override the generator tag. I'm working on a proper solution to allow the rest of the meta tags added by core to be disabled.

seandunaway’s picture

-    'element' => array(
-      '#id' => 'system_meta_generator',
-    ),

Dave, why not use the same id of system_meta_generator (versus metatag_generator) for other modules which might rely on it?

seandunaway’s picture

Version: » 7.x-1.x-dev

While I don't think it's a big issue because your module duplicates its functionality, this change did cause some confusion at #1460374: Display a warning in the site status page when Metatag module is installed and enabled....

KhaledBlah’s picture

Thx for your code, reatcory! This helped me!

Dave Reid’s picture

@rump: Because then we can't actually "disable" the meta tag in this case because we'd need to override it with something. It was easier to provide a default with our own ID and same values as core, and unset the core implementation.

DamienMcKenna’s picture

Assigned: Dave Reid » Unassigned
DamienMcKenna’s picture

Title: Need to be disable meta tags provided by core (generator, shortcut icon, shortlink) » Need to be able to disable meta tags provided by core (generator, shortcut icon, shortlink)
Category: bug » feature

This is a feature request.

GiorgosK’s picture

another way may be to modify meta tags would be using the hooks provided by metatags module
look in metatag.api.php for what hooks you can use

EDIT: spoke too soon, even if you use metatags.api to unset (practically disable) shortlink the default is inserted on each page, I had to finally use reatcory's code to accomplish this

bruceclothier’s picture

More of a work around than a solution but if you are using Metatags - http://drupal.org/project/metatag - (which you probably are if you are reading this post), you can override the default shortlink with the current node aliased path. Google probably won't spank you for that much... [yoursite]/admin/config/search/metatags/config/node > advanced. Incidentally leaving it blank doesn't remove it, i tried that.

DamienMcKenna’s picture

@bruceclothier: Leaving it blank just means that Drupal core's default will be used instead.

DamienMcKenna’s picture

DamienMcKenna’s picture

Issue summary: View changes

Updated case information

xibun’s picture

How about adding a <none> feature as known from block titles?

I suggest that when one sets <none> as the Shortlink URL then the tag will be removed from the output. And the description below the Shortlink URL field could be: "Use <none> to remove the shortlink tag from the output, or leave blank to use the default shortlink tag."

yingtho’s picture

Issue summary: View changes
Status: Active » Needs review
1.3 KB
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View

It did a token [metatag:delete] which will delete the metatag. So user can see it in availeble tokens. Could not use <none> as this value get strips in metatags (possibly to prevent hijack injection).

yingtho’s picture

639 bytes
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View

Can't use [metatag:delete] as all values with metatag in front get stripped. So using [delete] instead.

DamienMcKenna’s picture

Status: Needs review » Needs work

I don't like "delete", I'm checking with Dave on what a better token would be (my vote is "ignore").

DamienMcKenna’s picture

Component: Code » Documentation
Category: Feature request » Task

Ok, after feedback from Dave I've actually tested this.

It turns out this is possible out to do out of the box, you just set the unwanted value to a blank value and the meta tag won't be output.

Just need to add an item to the README.txt about it.

DamienMcKenna’s picture

Status: Needs work » Needs review
967 bytes
PASSED: [[SimpleTest]]: [MySQL] 73 pass(es). View

Changes for the README.txt file.

DamienMcKenna’s picture

Status: Needs review » Fixed


  • DamienMcKenna committed 449704c on 7.x-1.x
    Issue #1304038 by DamienMcKenna: Indicate in the README.txt how to...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

2pha’s picture

Version: 7.x-1.x-dev » 7.x-1.4
Category: Task » Support request
Status: Closed (fixed) » Active

I just upgraded to 7.x-1.4 and I can not remove the shortlink meta tag.
I can remove the generator meta by setting it to a blank textfield, but setting the shortlink metatag to a blank textfield outputs the default shortlink on the page.
Am I missing something?

DamienMcKenna’s picture

Status: Active » Closed (fixed)

@2pha: Please open a new issue so we can work through this one specific tag. Thanks.

mortenthorpe’s picture

This is patch from comment #15, modified to work with version 1.5 of Metatag module.

deminy’s picture

#25 works but seems to has side effect on frontpage (and probably somewhere else). Saying having shortlink "[delete]" applied at global level or frontpage level (sorry I couldn't remember which one), you will see following HTML content in header part of the frontpage:

<link href="[delete]" rel="shortlink">

Summit’s picture

I would very much like to be able to remove some fields from metatag output and have the title tag on top.
Is this the issue the right one to ask? I do not want to hiijack an issue..

I would like to remove these:

<link rel="shortcut icon" href="http://www.kasteelcampings.nl/sites/all/themes/bizreview/favicon.ico" type="image/vnd.microsoft.icon" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="HandheldFriendly" content="true" />
<meta name="MobileOptimized" content="width" />
<meta name="generator" content="Drupal 7 (http://drupal.org)" />
<link rel="canonical" href="http://www.kasteelcampings.nl/regio/duitsland" />
<link rel="shortlink" href="http://www.kasteelcampings.nl/taxonomy/term/2384" />
<meta property="og:site_name" content="www.kasteelcampings.nl" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.kasteelcampings.nl/regio/duitsland" />
<meta property="og:title" content="Duitsland" />
<meta name="dcterms.title" content="Duitsland" />
<meta name="dcterms.type" content="Text" />
<meta name="dcterms.format" content="text/html" />
<meta name="dcterms.identifier" content="http://www.kasteelcampings.nl/regio/duitsland" />

Thanks a lot in advance for your reply!

DamienMcKenna’s picture

@summit: Please open new issues for this rather than posting on an issue that was closed 10+ months ago.

Summit’s picture

Hi Damien,
Sorry, made new issue; https://www.drupal.org/node/2580003
greetings, Martijn