2

I am having a Sitecore SXA (1.5) instance site which has multiple language for each country. For example:

www.mysite.be/fr-BE (Country: Belgium, Lang: French)

www.mysite.be/nl-BE (Country: Belgium, Lang: Dutch)

But the sitemap.xml shows only urls which have the default language setup without any language id in the URL

Example here is my sitemap.xml output:

<url>
<loc>www.mysite.be/onze-producten</loc>
<lastmod>2018-12-12</lastmod>
<changefreq>Daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://www.mysite.be/over-merk</loc>
<lastmod>2018-12-12</lastmod>
<changefreq>Daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://www.mysite.be/contacteer-ons</loc>
<lastmod>2018-12-11</lastmod>
<changefreq>Daily</changefreq>
<priority>0.5</priority>
</url>

But it doesn't shows pages related to French language. For example:

www.mysite.be/fr-be/contactez-nous

www.mysite.be/fr-be/faq

If this is a custom implementation, please guide.

EDIT:

As per the answer below I tried making this to work, but no luck:

public class CustomSiteMap : SitemapGenerator
    {
        protected override StringBuilder BuildSitemap(IEnumerable<Item> childrenTree, SitemapLinkOptions options)
        {
            var items = LanguageSitemap.GetSitemapItems();// gets all items below Home node
            var xDocument = LanguageSitemap.Generate(items); // generates sitemap xml with hreflang and language specific urls
            return new StringBuilder(xDocument.ToString());
        }
    }

1 Answer 1

1

SXA supports multiple languages Sitemap from SXA 1.6- check the release notes here for more details-

The SEO Sitemaps aggregate all the available sites under a single hostname, and support multiple languages  494598  9788

In your case you can customized the Sitemap XML generator for your SXA version, follow the below steps:

1) Create a new class that inherits from SitemapGenerator

2) Override BuildSitemap() method- Here you can write your own code/business logic and generate the customized sitemap.xml to support multiple languages.

I hope this helps to give you a starting point.

1
  • Hi Ankit, I tried this, but its not working. It is still displaying the default Sitemap.xml which SXA generates. Even tried to debug my method, but its not hitting the breakpoint. Please check my updated question above. Commented Dec 31, 2018 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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