Comments

2pha’s picture

Status: Active » Needs review
StatusFileSize
new724 bytes

As I said, I'm not sure about the x-default as it seems hard to get good information.
But here is a patch that sets x-default for the default language.

Status: Needs review » Needs work

The last submitted patch, 1: hreflang-x_default-2376417-1.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
Issue tags: -x-default
StatusFileSize
new776 bytes

This should work.

Status: Needs review » Needs work

The last submitted patch, 3: hreflang-n2376417-3.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new787 bytes

Rerolled.

joelpittet’s picture

Title: no x-default ? » Add x-default
Category: Support request » Feature request

@DamienMcKenna should this be an option instead of forced in there?

And should it be additional to the normal hreflang? or should it override the language code of the default like you have it?

2pha’s picture

I could not find any real specific information on if you would have both default and en for a site that was default english, but from what I read it suggested that default would be enough.

joelpittet’s picture

Yeah me neither, I did have some negative results testing it with this tool though when I had both, so maybe this is the right way, just curious...

http://flang.dejanseo.com.au/

mfb’s picture

This doesn't make any sense to me; this will make an x-default hreflang tag for any pages in the site's default language. But you would only want to use x-default for a language-neutral front page that just has a language switcher or language map.

Not sure this module needs to support this as it's probably uncommon, and such a site could use hook_html_head_alter() in its custom code to setup the x-default tag on the front page

damienmckenna’s picture

I'm starting to wonder if this variation of the meta tag should be handled by the Metatag module instead, so it could be handled per entity. Thoughts?

2pha’s picture

@mfb.
I thought it was meant to be on every page so that google would know that "mysite.com/mynode" and "mysite.com/es/mynode" are the same node for different languages. That how I understand it.

@DamienMcKenna
I think the metatag module is probably the way to go.

joelpittet’s picture

@see https://support.google.com/webmasters/answer/189077?hl=en

For language/country selectors or auto-redirecting homepages, you should add an annotation for the hreflang value "x-default" as well:

mfb’s picture

Status: Needs review » Needs work

@2pha the link you put up in the issue description is pretty clear that x-default is for international landing pages, or pages that dynamically alter their content for the user.

This module doesn't automagically know that a page is an international landing page or that it dynamically alters its content - and that seems like a difficult thing for it to know given the variety of ways a Drupal site could render content. I'd say it's up to a site developer to setup the correct link tags in these cases, but I'm open to patches if someone has an idea for something useful here.

Until then this module is handling only the use case of a site with a default language, and other languages available in a language switcher (I think of the link tags as a machine-readable language switcher).

2pha’s picture

@mfb
Maybe that link was not the best one, the one linked to by joelpittet is better and as he quoted it does seem like x-default is only for "international landing pages, or pages that dynamically alter their content for the user".
The example on the bottom of that page suggests to me that x-default should be used on all pages, even though in the example the use the homepage. Maybe my interpretation of "international landing page" or "pages that dynamically alter their content" is different.

"Until then this module is handling only the use case of a site with a default language, and other languages available in a language switcher (I think of the link tags as a machine-readable language switcher)."
This is exactly my use case, but I have interpreted the documentation for x-default that you should have it on every page and it should point to the url of the page in the default language (which should be the same as the canonical).

After looking into it again I am still seeing conflicting views in blog posts and comments on the use of x-default, so I though I would check how google is doing it for their sites. Checking the google store site, it seems that they set x-default on all pages.

Here is the hreflang section from the page of a game on the google store. You can see that the include an x-default, but also a specific english hreflang (I am assuming at this point that the default page is in english). This suggests to me that x-default should be on every page, but not override the default language specific hreflang

<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal" rel="canonical">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal" hreflang="x-default" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=af" hreflang="af" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=in" hreflang="in" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=ms" hreflang="ms" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=ca" hreflang="ca" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=cs" hreflang="cs" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=da" hreflang="da" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=de" hreflang="de" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=et" hreflang="et" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=en_GB" hreflang="en_GB" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=en" hreflang="en" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=es" hreflang="es" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=es_419" hreflang="es_419" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=fil" hreflang="fil" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=fr" hreflang="fr" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=fr_BE" hreflang="fr_BE" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=fr_CA" hreflang="fr_CA" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=fr_FR" hreflang="fr_FR" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=hr" hreflang="hr" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=zu" hreflang="zu" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=it" hreflang="it" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=sw" hreflang="sw" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=lv" hreflang="lv" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=lt" hreflang="lt" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=hu" hreflang="hu" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=nl" hreflang="nl" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=nl_BE" hreflang="nl_BE" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=nl_NL" hreflang="nl_NL" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=no" hreflang="no" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=pl" hreflang="pl" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=pt_BR" hreflang="pt_BR" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=pt_PT" hreflang="pt_PT" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=ro" hreflang="ro" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=sk" hreflang="sk" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=sl" hreflang="sl" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=fi" hreflang="fi" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=sv" hreflang="sv" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=vi" hreflang="vi" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=tr" hreflang="tr" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=el" hreflang="el" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=be" hreflang="be" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=bg" hreflang="bg" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=ru" hreflang="ru" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=sr" hreflang="sr" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=uk" hreflang="uk" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=am" hreflang="am" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=hi" hreflang="hi" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=th" hreflang="th" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=ko" hreflang="ko" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=zh_HK" hreflang="zh_HK" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=ja" hreflang="ja" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=zh_CN" hreflang="zh_CN" rel="alternate">
<link href="https://play.google.com/store/apps/details?id=com.gamevil.darknessreborn2.android.google.global.normal&amp;hl=zh_TW" hreflang="zh_TW" rel="alternate">

Does all this make sense? At this point it is doing my head in and I am not even sure if we are talking about the same thing. It late here, I'm going to bed :)

mfb’s picture

The reason google has an x-default tag for https://play.google.com/store is because this page dynamically alters the language for the user by geolocating the user's IP address. If you load https://play.google.com/store from Germany, it will be in German; if you load https://play.google.com/store from the US, it will be in English. You can easily test this by accessing it with Tor Browser. (If you are logged in to Google, then it should default to your user account's language, rather than using your geolocated IP address.)

2pha’s picture

Ahh, yes, I see now that by dynamic they mean changing the content via a url parameter or something else, rather than a different url.

2pha’s picture

I have noticed now that when you turn off "Determine the language from the URL (Path prefix or domain)." and turn on " Determine the language from a request/session parameter." so it uses a url parameter to set the language (?language=en by default), then you get unexpected results for the hreflag meta tags.
When using request/session parameter, I only get 1 hreflang meta tag which is wrong.

Maybe I should start a new issue for this?

mfb’s picture

ok this module wasn't working with session detection, but I just fixed it and added a test, so we don't need a new issue. I'd say an x-default tag does make sense for session detection, basically each page could specify the URL without language parameter as x-default, and then we would also need to add the missing language parameter to the default language's hreflang tag.

2pha’s picture

I just tried latest dev and it does indeed work for session detection.
This confuses me:
"and then we would also need to add the missing language parameter to the default language's hreflang tag".
Isn't that the point of x-default? that any missing would default to the x-default?

mfb’s picture

Currently, if the default language is "en", at http://www.example.com/ there is an hreflang tag with hreflang="en" and the URL is missing the language parameter. Meanwhile at http://www.example.com/?language=fr there is an hreflang tag with hreflang="en" and the URL has "?language=en". Seems like this inconsistency should ideally be fixed.

Status: Needs work » Needs review

rekano queued 5: hreflang-n2376417-5.patch for re-testing.

mfb’s picture

Status: Needs review » Needs work

This issue still needs work as per previous comments

j-lee’s picture

StatusFileSize
new1.22 KB

I have modified the patch from #5 because we need x-default and all languages as link.

drupal_add_html_head_link overrides existing links so i used drupal_add_html_head directly.

Because this was a quick and dirty patch, I think there is a better solution for this.

damienmckenna’s picture

Status: Needs work » Needs review

Triggering the testbot on the patch in #23.

Status: Needs review » Needs work

The last submitted patch, 23: hreflang-x-default-2376417-6.patch, failed testing.

j-lee’s picture

Status: Needs work » Needs review
StatusFileSize
new745 bytes

After monitor a page and further investigations, x-default must return the frontpage url if it is a language neutral frontpage.
E.g. http://www.mypage.com/ shows english content or german content, depending on the language negotiation.

The patch implements this, but does not check if the page has a language neutral frontpage.

j-lee’s picture

StatusFileSize
new1.39 KB

Leading the x-default to the front page is definitely wrong.
Fixing patch from #23.

Status: Needs review » Needs work

The last submitted patch, 27: hreflang-2376417-27.patch, failed testing.

j-lee’s picture

StatusFileSize
new1.41 KB
rolfmeijer’s picture

Status: Needs work » Needs review

The patch from #29 applied to 7.x-1.2 and works as expected. It also works in combination with domain and domain_locale, it gets the default language of the current domain. Nice.

Status: Needs review » Needs work

The last submitted patch, 29: hreflang-2376417-27.patch, failed testing.

alphex’s picture

Can confirm, #29 works for me as well.

giupenni’s picture

#29 works for me as well.

j-lee’s picture

Status: Needs work » Needs review
StatusFileSize
new1.04 KB

This patch should work with the test.

Status: Needs review » Needs work

The last submitted patch, 34: add_x_default-2376417-34.patch, failed testing. View results

rcodina’s picture

Status: Needs work » Needs review
StatusFileSize
new992 bytes

I update the patch so it applies with latest dev version.

rcodina’s picture

@mfb Could you please test this patch? Thanks!

gauladell’s picture

#36 works for me

mfb’s picture

mfb’s picture

Status: Needs review » Needs work

The bug in core is fixed now so we should be able to use drupal_add_html_head_link()

mfb’s picture

Status: Needs work » Needs review
StatusFileSize
new5.81 KB

I added an opt-in setting for the hreflang="x-default" tag (so we don't break things for sites that weren't expecting changes to their hreflang tags) and a test for the new functionality.

mfb’s picture

Issue tags: -Needs tests
mfb’s picture

StatusFileSize
new5.76 KB

Just realized this module hasn't been specifying $header = TRUE when calling drupal_add_html_head_link(), so backing out my unintentional change there.

  • mfb committed 0d0cd7c on 7.x-1.x
    Issue #2376417 by mfb, J-Lee, DamienMcKenna, 2pha, rcodina: Add x-...
mfb’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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