Dynamic sitemap.xml generator

14 May 2016

Sitefinity provides a very good platform for Content Management System and also exposes many APIs through which developers could access the data, customize and render it according to their requirement.

If you have a smaller website(pages less than 1000), then you can use the following code to generate the sitemap XML and cache it for particular duration.

This code utilizes Sitefinity Page API (I know SitemapBase is cached and better with performance), but this page api gives you better control the pages from the multiple languages with the permission checking included. This code also takes care of situation where sites are hosted using Sitefinity MSM feature and generates the pages based on current MSM site.

Sample code from GitHub loads here !!!