-1

I have a website with two languages, which works in this format:

example.com/changelanguage.xx?lang=de

and redirects to German language

and calling the same URL again like:

example.com/changelanguage.xx?lang=​en

redirects to English language.

The URL remains the same example.com after redirection, just the language changes.

How to add the hreflang attribute here (for Google indexing)?

unor
  • 92,415
  • 26
  • 211
  • 360
user1482800
  • 83
  • 2
  • 12
  • If the user is on a page like `/about` or whatever, can the user switch the language from there to go to the German translation? If yes, also by visiting the URL you posted, or would the URL be different? – unor Aug 25 '16 at 18:01
  • Hi Unor, thanks for replying, There is a dropdown for language selection on each page and URL to change remains the same, he is redirected to original page requesting redirection. Please advise my main requirement is to do indexing by Google, thanks – user1482800 Aug 26 '16 at 04:50

2 Answers2

1

It’s a bad practice to use the same URL for different (i.e., translated) content.

Consumers, like search engine bots, would use rel-alternate + hreflang markup to find translations. For this to work, you have to provide a different URL for the translated page.

From the perspective of the search engine, it doesn’t work for their users if using the same URL: when they give http://example.com/foobar as search result, they want to make sure that their users get the language the search engine intended (e.g., someone searching for German terms should get the German page). But with your system, this doesn’t work; the search engine user might end up with the English version.

Instead, you should represent the language in the URL, e.g. the language code as first path segment:

http://example.com/en/contact
http://example.com/de/kontact

(Or use different domains/subdomains, or add a query parameter, etc. If you can make sure that translated pages would never have the same URL slug, you could even omit the language codes.)

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • Hi, I realise it is not best practice but I am using an erp to host this website, this is already live and I cannot alter structure. Is there something I can do to index it with both languages? Please advise – user1482800 Aug 27 '16 at 04:21
  • Hi, please let me know if there is a way to do it without changing the url structure... – user1482800 Aug 30 '16 at 13:30
  • @user1482800: As I wrote, for the `alternate`/`hreflang`markup to work, "you have to provide a different URL for the translated page". -- An alternative would be to include all languages in the same page and let the user hide/display languages via CSS/JavaScript -- unusual, but technically possible (but unclear how actual search engines would handle this; discussing this is off-topic on Stack Overflow). – unor Aug 30 '16 at 14:02
0

This is a year late but https://www.bablic.com/ do exactly this!

Furthermore they can automatically detect the language set in the user's browser and automatically show the user your website in that language!

Jonathan
  • 10,792
  • 5
  • 65
  • 85