Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hreflang tag to default language #819

Closed
wants to merge 1 commit into from

Conversation

antonzol
Copy link

If flag Hide URL language information for default language is active - hreflang to default language anyway include lang-pach.
Changing qtranxf_convertURL to defalult false - fix this problem

If flag Hide URL language information for default language is active - hreflang to default language anyway include lang-pach.
Changing qtranxf_convertURL to defalult false - fix this problem
@herrvigg
Copy link
Collaborator

I don't think we should this, see this discussion in #198.
More explanations about the redirections and hreflang are given in a page that i moved to this wiki: https://github.com/qtranslate/qtranslate-xt/wiki/Browser-redirection

It is a bit difficult to understand but the reason to have the explicit language even with the option "hide default language" is to resolve the ambiguity from requests generated from SEO robots, despite the fact it generates a temporary redirection (i.e. the URL stored by the SEO is not a canonical one in that case).

@herrvigg
Copy link
Collaborator

herrvigg commented May 3, 2020

See #826: added a new filter qtranslate_hreflang. This leaves you the freedom to do whatever you want there. I propose to close like this.

@herrvigg
Copy link
Collaborator

This topic is quite a complex question. I'm not sure about the right answer. Still need to think more about it...

@herrvigg
Copy link
Collaborator

herrvigg commented May 30, 2020

@antonzol I've reflected on this and i think the main behavior of qTranslate is correct in the default case. This is explained in the Wiki about redirections but maybe it is easier to understand with an example. I will take the example from #198.

<link hreflang="hu" href="http://example.com/hu/somepageslug" rel="alternate" />
<link hreflang="de" href="http://example.com/de/somepageslug" rel="alternate" />
<link hreflang="en" href="http://example.com/en/somepageslug" rel="alternate" />
<link hreflang="x-default" href="http://example.com/sompageslug" rel="alternate" />

In this example the default language on the server is hu and we use the option "hide default language" (otherwise we would not have this problem).

The question is about the first link. You would want it to use the default URL without language (like the one of x-default) instead of the URL with hu like this:

<link hreflang="hu" href="http://example.com/somepageslug" rel="alternate" />

Problem: with that link, qTranslate will normally negotiate the language the first time with your browser and store it in a cookie. Let's consider:

  • a "standard user" in hungary will get hu
  • a "standard user" in germany will get de
  • a german user living in hungary who prefers german will get de (browser settings)
  • and so on... with all possible combinations

The result is said to be non-deterministic: you don't know in advance the result because it depends on user parameters. So it would be wrong if the SEO assumes the default link is always hu. This would only be valid for the first user here but not the two others. It is correct to use hreflang=hu for URL hu (and this may cause a redirection for the first user!). Instead we rely on the hreflang=x-default for the default URL, though you consider it to be only hu (but it's not).

However - there is one special case mentioned by @nb000 in #198. If you disable the language negotiation (Languages / General / Detect Language Browser) you could assume the language is going to be fixed, therefore deterministic. In that case, the hu could be enforced to the default link because it would always be for that language.

Also one very extreme case would be if the user changes the cookie by external means, or for some reasons already have this cookie set (because the website had the auto detection first and removed it later). We may even consider the two conditions together (disable auto detect AND disable cookie) but maybe this is a bit of overkill.

Does this make it clearer?

herrvigg added a commit that referenced this pull request May 31, 2020
Only if the language is detected by the browser, enforce the
language shown to make the default URL deterministic for SEO.

Otherwise, allow the option "Hide URL language information
for default language".

Note the "x-default" item is not concerned by these changes,
this link always uses the default URL with no override.
@herrvigg
Copy link
Collaborator

@antonzol i have now pushed a new change to fix the problem raised in #198 (very old ticket).

Description of the fix:
Only if the language is detected by the browser, enforce the language shown to make the default URL deterministic for SEO.
Otherwise, allow the option "Hide URL language information for default language".
Note the "x-default" item is not concerned by these changes, this link always uses the default URL with no override.

I have updated the Wiki with all these clarifications about the redirections especially with a new clear section for the SEO and hreflang.

So in short: if you want the behavior you asked in first hand, simply disable the browser detection. This keeps all the hreflang consistent and it requires no change anymore. Possibly don't use the new filter qtranslate_hreflang because i'm not sure i will keep it. I propose to close the PR with the fix (concerning #198).

@herrvigg herrvigg added the core Core functionalities, including the admin section label May 31, 2020
@herrvigg
Copy link
Collaborator

herrvigg commented Jun 7, 2020

@antonzol can we close this?

@herrvigg
Copy link
Collaborator

herrvigg commented Sep 5, 2020

@antonzol i prefer to close this for now with the information given in this thread. You can still comment on this issue if you feel something is not clear.

@herrvigg herrvigg closed this Sep 5, 2020
@antonzol antonzol deleted the patch-1 branch September 6, 2020 13:47
@herrvigg
Copy link
Collaborator

@antonzol fix released in 3.9.0 when the browser detection is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core functionalities, including the admin section
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants