Sitemap xml multiple languages support with Sitecore SXA

When working with multilingual websites you might want to tell google about localized versions of your pages so that it helps google to point users to the most appropriate version of your page by language or region, you can find more details about this here.

If you are already into Sitecore SXA 1.6-  the feature is inbuilt and doesn’t needs any customization- see the Sitecore SXA 1.6 release notes here for ref., but if you haven’t upgraded yet you have to write some custom code to support this configuration/feature.

In this case what we have to do here is:

  1. Create a new class that inherits from SitemapGenerator (part of Sitecore.XA.Feature.SiteMetadata )
  2. Override BuildSitemap() method.

You can write your own code under BuildSitemap() method and generate the customized sitemap.xml to support multiple languages.

Once you make this change- you will see sitemap.xml in the below format (below example shows three language versions of home page)

sitemap-multilang

Hope this helps and you can use this solution until you move to SXA 1.6.

Happy learning 🙂

SXA redirect URL with country code

It is important to redirect user to new page from old page when we create new version of an existing web page, it helps both users and search engines to get redirected to a new URL from the one they originally requested.

sxa-redirects

There are several ways to setup redirects in Sitecore solution, with Sitecore SXA we have redirect tool in place that facilitates setting up old and new URLs in Sitecore. We can use the mapping tool to set up a 301/302 or server transfer redirect.

Recently we worked on setting up redirects using SXA redirect tool, for most of the redirects we had country code in the old URL.

Here are some example URLs:

Old URLen-au/sample-old-page-name   New URL– /new-page-name

Old URLen-au/mypage/pagelisting   New URL– /newpagelisting

What we observed that after setting up old URLs which has country code on it- all such URLs were redirecting to 404 page.

We can fix this by appending “sc_lang” querystring parameter to the new URL with the target country code, see below examples for ref:

Old URL– /sample-old-page-name   New URL– /new-page-name/?sc_lang=en-AU

Old URL– /mypage/pagelisting   New URL– /newpagelisting/?sc_lang=en-AU

After this redirects works as expected.

I hope this helps.

Happy Learning 🙂