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.
Hi all,
I am trying to add words for Meta Title, Meta keywords and Meta Description but I can only see fields for 'keywords' and 'Description'. Am I missing a Meta Title field?
Thanks
Comment | File | Size | Author |
---|---|---|---|
#16 | meta_title_field-1160402-16.patch | 4.38 KB | Xen |
Comments
Comment #1
valthebaldTitle is not a meta tag. If you want to manage it, please use http://drupal.org/project/page_title module
Comment #2
Juc1 CreditAttribution: Juc1 commentedOK, thank you.
Comment #3
skorzhAs a workaround, you can add a new field (field_meta_page_title)
And add this code to your template.php file:
Comment #4
Xen CreditAttribution: Xen commentedWhile the title isn't a meta tag, it's quite possible to create a meta title tag. There's generally much confusion of the two, som SEO people talking about 'meta title' when they in fact mean the title tag, and no-one seems to be able to prove any advantages to using meta title.
However, it can be put to good use nevertheless. Attached patch defines the title meta tag, and provides a new formatter for meta tags that sets the page title. Apart from allowing those wanting the title meta tag to use it, it can be used to make meta title act as an override for the title. This means moving in on page_title territory, but metatags_quick have the advantage of also working on non-node pages. It also makes sense as meta tags is the focus of SEO folks, and the other big SEO thing is ensuring the proper title, which isn't always best title for the node.
Also worth noting that it seems that the metatag module supports a 'meta title' element by setting the page title.
Comment #5
arrubiu CreditAttribution: arrubiu commentedI've tryed instruction in #3, but I notice that the drupal_add_html_head() returns me metatags_quick values only in not-node pages.
Is it normal?
Comment #6
kaldimar CreditAttribution: kaldimar commented#3 worked fine for me on path-based pages
Comment #7
stella CreditAttribution: stella commentedThe patch from comment #4 above works great, except that it also changes the h1 title printed on the page. I'm looking for a solution that allows me to have a completely different title in the
<title>
tag and also allows me to override the default pattern (ie. including the "| sitename" part).The attached patch builds upon the one from comment #4. Basically when the display formatter is set to "default metatags_quick formatter" and the meta tag field is the title, it sets the "title" tag in addition to the meta tag of type "title". This allows me to have a different page title from the one in the h1 tag, and also allows me to remove the "| sitename" or change it in whatever way I wish.
Comment #8
valthebald#7: thanks for a great amount of work. While the patch looks ok from the first sight, I would like to hear some responses if we need such a functionality inside metatags_quick (and not page_title, for example)
Comment #9
stella CreditAttribution: stella commented@valthebald I guess one of the real benefits of this module over page_title is the ability to specify it for non-node pages, such as Views and Panels, that's why I did i this way.
Comment #10
valthebald@stella: sounds like a valid use case, I never considered that
Committed to 2.x-dev, thank you!
Comment #12
John Carbone CreditAttribution: John Carbone commentedFound an odd bug in this. The patch in #7 doesn't work unless the page_title module is present and enabled.
If I turn off the page_title module, the functionality added by #7 above stops working. I'm using the metatag module suite and had page_title enabled as well as metatags_quick. I'm completely dropping page_title from the mix as it's no longer wanted/needed.
My use case was that the metatags modules left a hole with adding tags to Views pages. My customer has no access to the Views admin area so it wasn't possible to allow them to update their own tags on Views pages using the metatag module suite. metatags_quick, along with Stella's patch above filled that gap.
Here's a patch that removes the (unexpected) page_title module dependency.
Comment #13
Xen CreditAttribution: Xen commented@John Carbone
Doesn't make sense, drupal_set_title() is *the* way to set the title. If drupal_set_title() doesn't work, you have something else that messes with the title.
Comment #14
John Carbone CreditAttribution: John Carbone commentedAgreed, it's a head scratcher. With regard to the possibility of some other code getting in the way, I don't have any custom code running that calls drupal_set_title directly although I do have something that runs drupal_get_title (which calls drupal_set_title with no parameters to get it).
Anyway, the original patch in #7 includes code that wasn't getting run in my testing. As far as I can tell, this was a simple oversight. The code below (from #7) was never getting hit because the patch was calling drupal_set_title directly, rather than using _metatags_quick_add_head (where the code below was added in #7). _metatags_quick_add_head does some cleanup on existing tags in the head and eventually calls drupal_add_html_head by default which "Adds output to the HEAD tag of the HTML page." Since the intent here is not to change the title of the page itself but rather to change the page title in the head of the document, this all seems logical to me, but maybe I'm missing something.
I have no experience with this module's code to speak of but it all makes sense to me. Perhaps stella or valthebald can point us in the right direction. :)
[EDIT] @Xen I'd only skimmed the issue and missed that you had submitted the first patch that got this moving in the first place. I leave it up to you guys to decide if you want to use it or not.
Comment #15
Xen CreditAttribution: Xen commentedOK, I'll have to reopen this issue, because the committed patch is broken, it results in duplicated title elements.
stella is right in the observation that drupal_set_title() messes with both the tag and the primary
page title, due to the fact that both use drupal_get_title().
However, the patch results in 2 title tags when using the default metatag formatter on a metatag named title, which results in invalid markup (only one title element allowed).
A solution to stellas issue would be to change the set title formatter to store the title, and have a hook_preprocess_html() override the
head_title
andhead_title_array
variables for the template.And I'm slightly piqued that the commit message credits only stella, thought most of the code is mine.
Comment #16
Xen CreditAttribution: Xen commentedNew patch.
This removes stellas addition and adds an option to the "Set page title" formatter to select the method used. There's the drupal_set_title method which can be used by those that prefer the meta title to override the node title on node view, and there's the preprocess_html for those that just want to set the title element in the head.
Comment #17
John Carbone CreditAttribution: John Carbone commented@Xen, love the idea of being able to pick drupal_set_title or just the head title.
BTW, after posting my previous comments I later found that the Omega theme was messing with the output I was getting. I should have been testing against a clean install. Sorry for the confusion.
Comment #18
Jim Kirkpatrick CreditAttribution: Jim Kirkpatrick commentedTested patch in 16 and looks good to me. Meta title tag is back, having replaced the duplicate title tag.
Comment #19
Jim Kirkpatrick CreditAttribution: Jim Kirkpatrick commentedComment #20
Jim Kirkpatrick CreditAttribution: Jim Kirkpatrick commentedUpgrading - this messes with SEO, and is invalid HTML on basically every page on the site using this module.
Comment #21
Xen CreditAttribution: Xen commentedCare to elaborate on that? What invalid HTML are you seeing?
Comment #22
Jim Kirkpatrick CreditAttribution: Jim Kirkpatrick commented@Xen, having more than one tag is invalid HTML5 (and 4). See http://www.w3schools.com/tags/tag_title.asp:
Your patch fixes it, so it's more the current release of the module generates invalid HTML.
Comment #23
Xen CreditAttribution: Xen commentedAh, I was confused as to which version we were talking about.
Yeah, current version produces invalid HTML.
Comment #24
loominade CreditAttribution: loominade commentedHere is an hotfix for this issue:
Comment #26
valthebaldFixed and pushed to 7.x-2.x http://drupalcode.org/project/metatags_quick.git/commit/f6d8702
Thanks everyone!
Comment #28
meramo CreditAttribution: meramo at Bright Solutions GmbH commentedI have to reopen the issue, as I have the latest dev build (7.2.9+1-dev) installed, and it produces exactly two tags. Can anyone please confirm that?
Comment #29
Nikolay ShapovalovI confirm, when I use widget "Default metatags_quick formatter".
There are 2 tags.
If I use widget "Set page title", there is only 1 , but this title generated by views.