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)