we have to solve a problem with Google not correctly indexing our multilanguage sites. We'll redesign our URLs in the future but until then we need some way to help Google find the different language versions while preserving convenience for the users, especially those that use already existing links.
First I'll explain our site URL structure a bit:
Assume we use the domain example.com
. Our application will then detect the language of the browser and display either the English or the German version of the page. The user can then change the language by clicking a link which results in the query parameter language=xx
being appended.
The currently selected language is stored in the session, thus if the user doesn't change the language every page will be displayed in the language that was selected last.
Here's a short example for a user with browser language DE:
example.com -> example.com/bar -> example.com/bar?language=en -> example.com
(German) (German) (English) (English now)
If the browser language is not supported or not provided, we assume English as a default.
So now, Googlebot will have problems with this, since example.com
could either return English or German content. Initially, Googlebot should get the English version but if the language change link is followed (or the german TLD is used, since example.de
redirects to example.com?language=de
) the German version would be delivered).
Another problem is that our page internal links don't carry the language parameter. Although we could change that (with some effort in some cases) those links (without the parameter) are already present on external German sites and thus must be supported somehow.
To overcome this, we thought of the following redirection strategy:
example.com -> no session yet: detect browser language
-> if DE, then 302 to example.com?language=de
-> if EN, then deliver the English content
-> we have session, so get the language from the session
-> if DE, then 302 to example.com?language=de
-> if EN, then deliver the English content
example.com/bar -> the same as example.com
example.de -> 301 to example.com?language=de
Each page would then additionally have the alternate
relation set, e.g.
<link rel="alternate" hreflang="en" href="http://example.com" />
<link rel="alternate" hreflang="de" href="http://example.com?language=de" />
So, from our point of view, the following should happen:
- The user opens
example.com
and either gets the English version or is redirected to the version matching the browser language (if supported) - The user clicks
example.com/bar
and depending on the language in the session (or the browser language if the URL is directly opened) either the English version is delivered or he's redirected toexample.com/bar?language=xx
. - Googlebot crawls
example.com
and since no language is provided it sees the English version, even when following the internal links
The real question here is:
As far as we know, there's no guarantee that Googlebot either uses a session id or doesn't use it, thus we don't know whether there is a session being reused during crawling.
Thus there are two possibilities:
If Googlebot uses a session, it might either get English content or a 302 redirect for any URL that lacks the language parameter (e.g.
example.com/bar
). How would Google handle that?If Googlebot does not use a session it would get the German version for
example.de
, due to the redirect. If it then follows an internal link toexample.com/bar
it should get the English content, since no language is provided and a new session is created. In that case, would Googlebot store the alternate linkexample.com/bar?language=de
for the German version?
Please note that we're working on redesigning our URLs to always have the language in the path (e.g. example.com/en/bar
) but that'll take a while and we also need to handle already existing links without the language. So please don't just suggest to restructure the URLs.
Edit:
As of request, here's the original problem that we're trying to tackle.
Our customer generally uses their .com
domain and they want the result pages to display a German description when using google.de and an English description in any other case.
However, the results are always displayed in English.
Our current (seemingly insufficient) approach is this:
example.com -> page in English or German, depending on the request language (and currently on the session as well)
-> alternate link with hreflang=en : example.com?language=en
-> alternate link with hreflang=de : example.com?language=de
We assumed that Google would be able to use the alternate language versions and display the best fitting version in a localized result page.
This, however, didn't work out so well yet and we assume one reason is that example.com
itself isn't an alternate link to anything. Thus we thought about leaving the language parameter out for the English version (see the question above) and use example.com
as the alternate link for hreflang=en
.
We're no SEO experts though, so this could be wrong. If so please correct me with some hints or explanations. :)
With this trail of though we arrived at the point where example.com
should represent the English version of the page only. However, if we change that, all German users (which are about 50% of the visitors) would first see the English page, because of the many links in the wild that don't contain any language parameter. And this is something our customer clearly doesn't want.
This again led us to the approach using redirects to example.com?language=xx
and calculating xx
from the browser language (and the session as well, if it contains language information).
language
URL param in every link to make this a canonical URL.