How to show a page in different languages?
Asked Answered
D

2

6

I use this meta tags to make google crawler know that I have two languages for my site, as suggested here support.google.

<link rel="alternate" hreflang="x-default" href="http://www.example.com" />
<link rel="alternate" hreflang="de" href="http://www.example.com/de" />
<link rel="alternate" hreflang="en" href="http://www.example.com/en" />

So sometimes the content of example.com would be the same as example.com/de and sometimes example.com would be the same as example.com/en.

I use the following code to detect language

const lang = (
     getLangFromUrl(req.url) || 
     getLangFromCookies(req.cookies) || 
     getLangFromHeader(req.headers) || 
     'de'
);

and google detects example.com and example.com/de as duplicated pages.

Can you please tell me how should it be correctly done?

Digressive answered 25/2, 2019 at 19:22 Comment(0)
P
2

Google has mentioned this issue in this link: support.google.com

If you prefer to dynamically change content or reroute the user based on language settings, be aware that Google might not find and crawl all your variations. This is because the Googlebot crawler usually originates from the USA. In addition, the crawler sends HTTP requests without setting Accept-Language in the request header.

I hope this will help you

Postlude answered 27/3, 2019 at 8:0 Comment(2)
ok, but what is x-default? I thought its an option to change content dynamically based on language setting or user choice. am I right?Digressive
Default page doesn't target any language or locale; has selectors to let users pick their language and region.Postlude
H
0

Handling duplicate pages with multilingual/multi-regional sites

If you provide similar or duplicate content on different URLs in the same language as part of a multi-regional site (for instance, if both example.de/ and example.com/de/ show similar German language content), you should pick a preferred version and use the rel=canonical element and hreflang tags to make sure that the correct language or regional URL is served to searchers.

You can find here the Google guide to Consolidate duplicate URLs: https://support.google.com/webmasters/answer/139066?hl=en

Halima answered 26/3, 2019 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.