Recently we faced this issue in our Sitecore SXA site which was non-multilingual but still there was language being embedded in sitemap.xml “alternate” node. Firstly we had ensured that the language embedding settings are properly in-place which are languageEmbedding=”never” and Languages.AlwaysStripLanguage=”false“.
After having these settings in place still we were able to see the language being embedded in sitemap.xml “alternate” node.
After digging into Sitecore Class (Sitecore.XA.Feature.SiteMetadata.Sitemap.SitemapGenerator) responsible for generating the rel=”alternate” node in sitemap and doing some research we found that some-how it does not follow the languageEmbedding option set in the configuration and that was because the method that it was using for generating the url had the object SitemapLinkOptions with languageEmbedding option set to “always” hardcoded in the code itself.
To resolve this issue we had override the GetFullLink method and set the languageEmbedding option to the value that was set through the config (which in this case is “never”).
Following is the code and config file changes that we needed to do.
After doing the above changes the “alternate” node in our sitemap.xml file was getting generated properly with no language being embedded in the url.
That’s all for this and hope this would be helpful for all of you.
Happy Sitecore-ing!