1

When I checked my site with Google Webmaster Tools, I saw a warn about a missing hreflang tag.

I have a one-page website which is multi-language – German and English. When first visited the language will be the same as the browser language. If the user switches the language a cookie is set to store the selected language. But the language is not indicated in the URL (e.g. /en or /de), it’s just mydomain.com in both cases. What I do is changing the lang attribute in the html tag in lang="de" or lang="en". I thought that would be friendly enough for Google.

My question is how to implement the hreflang correctly. All the example I find deal with different language folders like mydomain.com/en/, subdomains en.mydomain.com or extensions mydomain.com/?lang=en.

Should I switch the hreflang tag dynamically via JS depending on the selected language, so when the user sees the English version the hreflang would be de-DE because there’s the same content also in German:

<link rel="alternate" href="http://example.com" hreflang="de-DE" />

And when the user sees the Website in German:

<link rel="alternate" href="http://example.com" hreflang="en-EN" />

But that’s seems odd because the href value would be the same in both cases …

user1706680
  • 1,103
  • 3
  • 15
  • 34

1 Answers1

1

You can only use Hreflang if you have 2 separate URLs. Then Google can send English users to the en page and the German users to the de page.

tinkerr
  • 975
  • 2
  • 14
  • 32