Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello!
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?
Thanks
Comment | File | Size | Author |
---|---|---|---|
#25 | metatag-delete-metatag-1304038-20.patch | 827 bytes | mortenthorpe |
#19 | metatag-n1304038-19.patch | 967 bytes | DamienMcKenna |
Comments
Comment #1
Fleshgrinder CreditAttribution: Fleshgrinder commentedI'm using the following function within my template.php file.
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.
Comment #2
not_active_999 CreditAttribution: not_active_999 commentedMost 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.
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!
reatcory.com
Comment #3
Dave ReidWith 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.
Comment #4
seandunaway CreditAttribution: seandunaway commentedDave, why not use the same id of system_meta_generator (versus metatag_generator) for other modules which might rely on it?
Comment #5
seandunaway CreditAttribution: seandunaway commentedWhile 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....
Comment #6
KhaledBlah CreditAttribution: KhaledBlah commentedThx for your code, reatcory! This helped me!
Comment #7
Dave Reid@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.
Comment #8
DamienMcKennaComment #9
DamienMcKennaThis is a feature request.
Comment #10
GiorgosKanother 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
Comment #11
bruceclothier CreditAttribution: bruceclothier commentedMore 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.
Comment #12
DamienMcKenna@bruceclothier: Leaving it blank just means that Drupal core's default will be used instead.
Comment #13
DamienMcKennaClosed a duplicate: #2116543: How to remove blank fields
Comment #13.0
DamienMcKennaUpdated case information
Comment #14
xibun CreditAttribution: xibun commentedHow 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."Comment #15
yingtho CreditAttribution: yingtho commentedIt 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).Comment #16
yingtho CreditAttribution: yingtho commentedCan't use [metatag:delete] as all values with metatag in front get stripped. So using [delete] instead.
Comment #17
DamienMcKennaI don't like "delete", I'm checking with Dave on what a better token would be (my vote is "ignore").
Comment #18
DamienMcKennaOk, 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.
Comment #19
DamienMcKennaChanges for the README.txt file.
Comment #20
DamienMcKennaCommitted.
Comment #23
2phaI 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?
Comment #24
DamienMcKenna@2pha: Please open a new issue so we can work through this one specific tag. Thanks.
Comment #25
mortenthorpe CreditAttribution: mortenthorpe commentedThis is patch from comment #15, modified to work with version 1.5 of Metatag module.
Comment #26
deminy#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">
Comment #27
Summit CreditAttribution: Summit commentedHi,
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:
Thanks a lot in advance for your reply!
Comment #28
DamienMcKenna@summit: Please open new issues for this rather than posting on an issue that was closed 10+ months ago.
Comment #29
Summit CreditAttribution: Summit commentedHi Damien,
Sorry, made new issue; https://www.drupal.org/node/2580003
greetings, Martijn
Comment #30
ressa CreditAttribution: ressa at Ardea commentedI was searching for info on how to disable shortlink, and found this page and just want to share Karen Stevensons new article Sending a Drupal Site Into Retirement Using HTTrack, with code which removes a few of the head elements added by Drupal 7 such as
shortlink
, for anyone else who ends up here, looking for info on how to do this.