Reputation: 11
How can i avoid duplicating hreflang tags in this situation:
Home : http://mywebsite.com -> use browser language (assuming what is french now)
<link rel=”alternate” hreflang=”fr” href=”http://mywebsite.com”>
<link rel=”alternate” hreflang=”fr” href=”http://mywebsite.com/fr”>
<link rel=”alternate” hreflang=”en” href=”http://mywebsite.com/en”>
Thank you specialists
Upvotes: 1
Views: 158
Reputation: 233
Languages should be unique within a hreflang group, and therefore you should not have multiple URLs for fr
within your hreflang definition. I recommend doing the following:
https://example.com/
as x-default so it will be used for all languages without a specification.<link rel="alternate" hreflang="x-default" href="https://example.com/">
<link rel="alternate" hreflang="fr" href="https://example.com/fr">
<link rel="alternate" hreflang="en" href="https://example.com/en">
https://example.com/
a redirect to the best matching language based on the Accept-Language
HTTP header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).When implementing the redirect, you need to be aware of some things:
Vary
HTTP header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) should be sent to indicate that the behavior of the URL changes based on the Accept-Language
HTTP header (Vary: Accept-Language
). Without this, search engine robots will not understand that they get a different behavior when accessing this URL with a different Accept-Language` HTTP header.In addition to these technical aspects, you should be aware that it is not really necessary to implement hreflang for different languages to get the correct language targeting, as search engines do quite well to distinguish languages e.g. French from English. Setting the proper language on the HTML tag <html lang="en">
is usually sufficient, and hreflang can add quite some overhead in terms of file size if you have a lot of different languages. Hreflang however is absolutely necessary when targeting multiple region with the same language e.g. Germany (de-DE
), Austria (de-AT
) and Switzerland (de-CH
).
Note: I also wrote a complete guide on hreflang a while back with a list of common mistakes to avoid.
Upvotes: 0
Reputation: 767
You can set the language and region via hreflang.
Examples:
de
: German language content, independent of regionen-GB
: English language content, for GB usersde-ES
: German language content, for users in SpainSource: https://developers.google.com/search/docs/advanced/crawling/localized-versions
The default specification is then x-default
value.
Source: https://developers.google.com/search/blog/2013/04/x-default-hreflang-for-international-pages
Upvotes: 0