2

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 _locale 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)

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.