skip to Main Content

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)?

2

Answers


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

    Consumers, like search engine bots, would use relalternate + 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.)

    Login or Signup to reply.
  2. 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!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search