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

Should I put my locale query param in sitemap url?

· 52CE 我爱测

I am currently generating my sitemap for my website, listing all pages generated by users (with pictures and datas). Those pages are publicly accessibles, and have content internationalized in french and english, depending on the…

问题原文

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

I am currently generating my sitemap for my website, listing all pages generated by users (with pictures and datas). Those pages are publicly accessibles, and have content internationalized in french and english, depending on the user's accepted language. It can be forced using the _lang query parameter.

should I use the following sitemap (including the query param in the loc) ? Or should I remove the query param from the loc, and keep it only in alternate ? (i removed other fields like lastmod, changefreq and priority for brevity)

<url>
  <loc>https://mywebsite.com/users/XXX/posts/YYY?_lang=en_US</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://mywebsite.com/users/XXX/posts/YYY?_lang=en_US"/>
  <xhtml:link rel="alternate" hreflang="fr" href="https://mywebsite.com/users/XXX/posts/YYY?_lang=fr_FR"/>
</url>

I believe that putting it in the loc would tell google that the canonical url is indeed with the locale parameter set to en_US. Would that pose a problem in term of search results or appearance ? (This link is displayed in various places without this query parameter)

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 3.0

You are correct that adding the locale parameter to the sitemap would let Google know that is the preferred canonical version of the URL. John Mueller who works at Google on sitemaps gives that as one of their uses in the Sitemap Paradox question.

Your use of including the parameter and setting alternate hreflangs in sitemap looks perfect. I wouldn't normally recommend using parameters for locale (see How should I structure my URLs for both SEO and localization?), but if you have done so, then you have to use the sitemap like you propose.

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

资料来源与适用范围

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

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

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