大网数据广告活动
网站运营与故障问答

Are hreflangs needed in the XML sitemap if they are used in the head of each page?

· 52CE 我爱测

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 d…

问题原文

原帖链接 · 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:

  1. HTML Tags
  2. HTTP Headers
  3. 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">

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2018-10-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。