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

Should I put hreflang in the sitemap if my site already has link tags containing hreflang?

· 52CE 我爱测

I am using hreflang between languages on a global website. My hreflang code is: <link rel=”alternate” href=”https://example.com/en/” hreflang=”en” /> <link rel=”alternate” href=”https://example.com/tr/” hreflang=”tr” /> <link rel…

问题原文

原帖链接 · ardacarofficial · CC BY-SA 4.0

I am using hreflang between languages on a global website. My hreflang code is:

<link rel=”alternate” href=”https://example.com/en/” hreflang=”en” />
<link rel=”alternate” href=”https://example.com/tr/” hreflang=”tr” />
<link rel=”alternate” href=”https://example.com/en/” hreflang=”x-default” />

Should I use also include hreflang in the sitemap?

<url>
<loc>https://example.com/</loc>
<xhtml:link
  rel="alternate"
  hreflang="en"
  href="https://example.com/en/"
/>

<xhtml:link
  rel="alternate"
  hreflang="tr"
  href="https://example.com/tr/"
/>

<xhtml:link
  rel="alternate"
  hreflang="x-default"
  href="https://www.deezer.com/en/"
/>
</url>

已采纳解答

原帖链接 · Mike Ciffone · CC BY-SA 4.0

TLDR: That is fine as long as they don't conflict with each other. For example if one country version of an hreflang directive appears on the page, but that same directive is assigned to a different page in the sitemap.

Google's John Mueller on hreflang directives being included in the sitemap and the source code of web pages

“What would happen there is we would combine those. From our point of view hreflang is not something where we say you can only have one language or country version on one page, but rather you can have multiple country versions on the same page. And you can have multiple different levels."

"So you could say this is the page for English in Singapore, English in US, English in UK, and you have a different page for English in Australia, for example. You can have one page with multiple country/regional targeting on them. So if you have some hreflang in the HTML, and some in the sitemap, then we would try to combine that and add that together. That means that if you have multiple different country versions across those different things we would just combine that into one setup.”

He also states where you can run into potential problems

“The one place where it would get confusing, or where we would see it as conflicting is if you have one country language version on the page and you use the same country language version for a different page in the sitemap file. That’s one situation where our systems would probably have to guess.”

Full Article

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

资料来源与适用范围

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

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

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