I have i18n and Entity Translation installed with fallback language.
There is a node written in only one language (Portuguese -Brazilian). Then going to http://www.example.com/en/node_title
displays the interface in English and the content in Portuguese because of the language fallback.
The canonical tag created is:
http://www.example.com/en/en/node_title
It should be:
http://www.example.com/pt-br/node_title
The way this is working right now the website can be penalized for duplicated content.
note: the issue of duplicated language on the canonical URL (/en/en/
) is already at reported at http://drupal.org/node/1205982 and maybe is related to this one
Comment | File | Size | Author |
---|---|---|---|
#6 | globalredirect-canonical-url-1208144-3.patch | 1.86 KB | jthorson |
#4 | 1208144-3-globalredirect-canonical-url.patch | 1.86 KB | Mac_Weber |
#2 | 1208144-globalredirect-canonical-url.patch | 1.86 KB | mrfelton |
Comments
Comment #1
Mac_Weber CreditAttribution: Mac_Weber commentedI just realize it happens only if at Global Redirect's config is not set the option "Language Path Checking".
However, it is interesting in some cases not redirect and have the canonical pointing to the original content. For example, in case the admin wants to keep the interface language yet the content is displayed on a different language.
Comment #2
mrfelton CreditAttribution: mrfelton commentedThis is a problem in Drupal 6 too, and it stems from the fact the url() function is being used to generate the canonical url. I have spent some time working through this issue, and come up with this patch which does the following:
1) If a node is language neutral, then the Canonical URL will point to the unprefixed version of the node, regardless of how you access the page. For example
node/1 has url alias my/page
visiting /my/page => canonical url = http://www.example.com/my/page
visiting /en/my/page => canonical url = http://www.example.com/my/page
visiting /es/my/page => canonical url = http://www.example.com/my/page
2) If a node is language specific, then the Canonical URL will point to the correct version of the node. For example
node/1 has url alias my/page and language en
visiting /en/my/page => canonical url = http://www.example.com/en/my/page
visiting /es/my/page => 404 error, nothing to do here
3) If a node is langage specific, and has translations in other languages then the Canonical URL will point to the correct version of the node. For example
node/1 has url alias my/page and language en
node/2 has url alias my/page and language es
visiting my/page => canonical url = http://www.example.com/my/page
visiting es/my/page => canonical url = http://www.example.com/es/my/page
This has only been tested with LANGUAGE_NEGOTIATION_PATH_DEFAULT, and is for Drupal 6. This also corrects the problem described in #1205982: multi-language globalredirect with pathauto creates bad canonical.
Comment #3
Mac_Weber CreditAttribution: Mac_Weber commentedmrfelton, thanks for the patch. I will test it and post a feedback.
Comment #4
Mac_Weber CreditAttribution: Mac_Weber commentedI just added the comment number to the file name, so it can pass by QA
Comment #5
jthorson CreditAttribution: jthorson commentedJust testing ... but I think the patch is against 6.x.
Comment #6
jthorson CreditAttribution: jthorson commentedComment #7
jthorson CreditAttribution: jthorson commentedComment #8
jthorson CreditAttribution: jthorson commentedComment #9
chicodasilva CreditAttribution: chicodasilva commentedHas anyone tested patch #6 for drupal 7?
Comment #10
anouHello,
I've tested patch #6 on Drupal 7. You have to add
$query_string
as argument of the new function:_globalredirect_get_canonical($path, $query_string) {...
But the function removes the language prefix...
So I just changed the canonical part :
and this way I don't have duplicate prefixes. I have a patch but I not sure that's the right place to attach it.