SXA site map implementation for “traditional” (non-SXA) Sitecore sites


Sitecore 9 comes with an interesting [optional] new module, the Sitecore Experience Accelerator (or “SXA” for short), which is a great way to produce ‘websites and to reuse components, layouts, and templates across a variety of sites’. The SXA enables you to create [by means of the underlying Sitecore PowerShell Extensions scripts] multiple sites, actually multiple tenants, as nodes in your Sitecore content tree, which can share templates and security roles.

This is all nice and dandy, but although you might want to create all your new sites as “SXA sites”, you might not be prepared to transition your existing [tried and trusted, potentially huge] “traditional” (i.e. non-SXA) sites to the SXA model just yet. Also, I’m not sure whether these have been ironed out, yet, but there seem to be some “complexities” in using federated authentication with an SXA site.

Still, the SXA comes with a bunch of new features, which it would be great if you could exploit on a traditional site… assuming you are licensed for the SXA module, of course. 😉 One of these is without a doubt the [automatically generated] site map, which is a hoary issue for standard Sitecore implementations, as all the clever site map modules out there are generally (some majorly) out of date —you might manage to get them to work with the most recent versions of Sitecore, but wouldn’t it be nice if you could use something that’s built into Sitecore itself? 😁

Well, it turns out that —thanks to the combined flexibility of Sitecore config patching, dependency injection and overridable [virtual] methods— it’s pretty straightforward to make the SXA site map work with traditional Sitecore sites, so here you go…


First of all, a word of warning: all this has been tested with Sitecore 9.3 (initial release) and the corresponding version of the SXA module. It might just work the same (possibly with some tweaks) with previous versions of Sitecore 9 and SXA, but I can’t guarantee it. 😉

It turns out that, code-wise, all you need to do is override one method of the SitemapHandler and one method of the SitemapGenerator. The first override is needed to tell Sitecore where to look for the site map settings [items] for your traditional sites. These are just instances of the SXA /sitecore/templates/Feature/Experience Accelerator/SiteMetadata/Sitemap/_SitemapSettings template, which you can put anywhere in your content tree, having taken note of their IDs.

Site map settings

When requesting /sitemap.xml, the override simply gets the site map settings item for the current site, falling back to the base method for any site you have not explicitly specified (and in particular for any SXA site).

The second override is to avoid skipping items that inherit from the [base] page template (or possibly templates) you use on your traditional sites (chaining it with the existing base method conditions).

The only thing left to do deployment-wise is patch the SXA Sitecore config patches to use your overrides, making sure that your patch gets loaded after the SXA ones, e.g. by putting it in the “usual” \App_Config\Include\zzz folder.

All we need to do now is make our base page template(s) [also] inherit from the /sitecore/templates/Feature/Experience Accelerator/SiteMetadata/Sitemap/_Sitemap template.

Site map settings

This way you can adjust the individual site map settings of each page on your site.

Site map settings

…And that’s it. Enjoy! 😁