问题原文
原帖链接 · Adam · CC BY-SA 4.0
I have a multi-language website like this:
example.com/de/about
example.com/fr/about
example.com/about (English)
I decided to put the hreflang link elements in the <head> of each file.
Now I wonder, is it enough to only put the default English URL in the sitemap like this:
<url>
<loc>example.com/about</loc>
</url>
or do I have to put every language version in the sitemap:
<url>
<loc>example.com/de/about</loc>
</url>
<url>
<loc>example.com/fr/about</loc>
</url>
<url>
<loc>example.com/about</loc>
</url>
已采纳解答
原帖链接 · John Could · CC BY-SA 4.0
Wherever you put the hreflang is fine you have to use only one of the above methods. Find the methods suggested by Google here: Tell Google about localized versions of your page
Methods for indicating your alternate pages There are three ways to indicate multiple language/locale versions of a page to Google:
- HTML Tags
- HTTP Headers
- Sitemap
From personal experience i would suggest using the head method
Sitemap:
Pros: More control over which pages have alternative language Easy setup (crawl and set)
Cons: Monthly Update
Head:
Pros: Process can be automate by variety of plugins and scripts out there
Cons: You can end up easily have hreflang issues on pages without alternative language (unless is done manually ignore this)
Note: Im not really sure what happens if you keep both but i find that unnecessary, keep it simple and healthy to avoid errors and eventually google ignoring your hreflang.
Examples
Using hreflang on sitemap.
Sitemap should look like this:
<url>
<loc>http://www.example.com/english/page.html</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="http://www.example.com/deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="de-ch"
href="http://www.example.com/schweiz-deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://www.example.com/english/page.html"/>
</url>
Header shouldnt include hreflang since we have it on sitemap.
<head> no hreflang </head>
Using hreflang on header
Sitemap should look like this
<url>
<loc>http://www.example.com/english/page.html</loc>
</url>
Header should look like this:
<link rel="alternate" href="http://www.example.com/deutsch/page.html" hreflang="de">
<link rel="alternate" href="http://www.example.com/schweiz-deutsch/page.html" hreflang="de-ch">
<link rel="alternate" href="http://www.example.com/english/page.html" hreflang="en">
<link rel="alternate" href="http://www.example.com/english/page.html" hreflang="x-default">
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
