Closed (fixed)
Project:
Metatag
Version:
7.x-1.x-dev
Component:
Other tags
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Oct 2015 at 13:58 UTC
Updated:
16 Dec 2015 at 20:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
damienmckennaOnce this is added we'll also add the x-default tag: #1969400: Add the hreflang="x-default" meta tag
Comment #3
damienmckennaOh, the other issue didn't actually *add* support, it just said "use this module instead." Doh.
Comment #4
damienmckennaThis should cover it. It adds the hreflang="x-default" meta tag and automatically adds hreflang tags for each enabled locale. It also, by default, removes any hreflang="LANGCODE" tags that match the x-default value, per Google's recommendation. There's a test file but it needs to be done later.
Comment #5
damienmckennaThis is what it looks like:
Comment #6
damienmckennaClosed a duplicate: #1969400: Add the hreflang="x-default" meta tag
Comment #7
damienmckennaGoing to be finishing this in time for the next release, just need to finish the i18n functionality first and then write some tests.
Comment #8
damienmckennaFYI I wrote a patch to add a token to the Entity Translation module that works really well with this: #2603056: Provide tokens for URLs of all available translations for a given entity
Comment #9
damienmckennaThis merges in the token from the other issue, sets up defaults based upon the token, and improves the help text.
Comment #10
damienmckennaA minor mistake.
Comment #12
damienmckennaA minor wording fix.
Comment #13
damienmckennaCommitted.
Comment #15
perignon commentedDeja vu. I just started looking for something to provide the hreflang tag today and was hoping metatag did before I threw the code into an existing custom module on my site.
Comment #16
perignon commentedWhat could cause this to not work? Something obviouse I am hoping.
I been testing this yesterday and this morning and I am not getting the metatags in the HEAD of the document of nodes.
I turn dupes on as well.
Comment #17
perignon commentedThis is my settings for my node. Since I do not have translations I only set the default to the source.
Comment #18
perignon commentedSo I installed on a default Drupal 7 and it works. Therefore it is something in my code base not allowing it to work. If you can throw me any ideas that would be much appreciated. Once I figure out they conflict we can document it if it is something someone else may run into.
Comment #19
damienmckennaIf you don't have translations installed then [node:source:url] won't have a value, it depends upon the $node->tnid value.
Comment #20
perignon commentedThat is rather interesting. You are right that I have the "Content Translation" module shut off. Why did it not throw an error that the tocketn [node:source:url] was not available?
Comment #21
perignon commentedSo the problem was the token being empty.
Is this worth documenting? I've also just found that even with the content translation module enabled that the token [node:source-url] is still empty. So for those of us just trying to get the default hreflang tag and have no other translations, you just need to use the node/page URL.
Comment #22
damienmckennaYes, it's worth documenting, and the default token stuff should probably check to make sure the module is enabled.
Comment #23
perignon commentedYeah.... We got more issues. I would suggest that the default values be empty. After installing the module on my production site I found I could not publish any nodes. All threw errors saying that [node:url-en] did not exist. And what I found was the default value got put into every configuration causing everything to have a token that doesn't exist. I've had to go through all of my metatag settings and overrides and remove the language-specific value.
Installing this module on a site without localization will "freeze" all publishing of the site till you correct the default values.
So I would recommend this get removed or changed so that it tests for the existence of the language specific token first:
Comment #24
perignon commentedOddly enough, even though I had not overrode the Node metatag configuration it had the wrong token in it after setting global configuration to what I need. Maybe just a fluke.
Comment #25
damienmckennaThat's strange, because the tokens are added by the module itself.
Comment #26
perignon commentedThe [node:url-LANG]?
Comment #27
damienmckennaYep :)
Comment #28
damienmckennaHow about this?
Comment #30
damienmckennaCommitted.
Comment #31
liampower commentedWhen testing this I found that it's not picking up the translated nodes within metatag_hreflang_tokens as the $node->translations wasn't displaying the translations found in the node translate tab.
I found that getting the translations using translation_node_get_translations($node->nid) returned my correct translations.
The below is what worked for my translations.
Comment #32
damienmckennaWere you using the core "Content translation" module or Entity Translation?
Comment #33
liampower commentedI didn't originally set this website up and it has both of the modules enabled but I believe the node was translated with 'Content Translation'
Within the publishing options Multilingual support the option: 'Enabled, with translation' is selected.
Comment #34
damienmckennaLets move this into a new ticket: #2627598: Custom tokens for hreflang not working