This excellent module is used on a large number of Optimizely sites, I think I use it on just about every site I have delivered, but today I found out a new feature that I didn’t know existed.
Perhaps I am late to the party, but I had a requirement for a client who is having problems with their sitemap. The catalog contained well over 50,000 products, well over the limit for a single sitemap file. This meant that we needed to generate multiple sitemap files.
Whilst I could reference these files in the robots.txt file, I really wanted to generate a single sitemapindex.xml file and just reference this.
I fired up dotPeek to have a look around and try and work out the best way of implementing this requirement myself and had various ideas until I stumbled upon the ‘GetaSitemapIndexController’. Turns out the functionality already exists.
Configure your sitemaps
In the example below I have created multiple sitemaps, and then for the commerce ones I have also specified the node id. This represents the category I want to generate within the sitemap.
Generated index file
The sitemap index file will automatically be returned in response to the request for sitemapindex.xml.
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap> <loc>https://www.xxxxxxxx.com/sitemap.xml</loc> </sitemap> <sitemap> <loc>https://www.xxxxxxxx.com/commerce-cat1-sitemap.xml</loc> </sitemap> <sitemap> <loc>https://www.xxxxxxxx.com/commerce-cat2-sitemap.xml</loc> </sitemap> <sitemap> <loc>https://www.xxxxxxxx.com/commerce-cat3-sitemap.xml</loc> </sitemap> </sitemapindex>
Whilst this may not be a common requirement for all sites, it is really useful for larger eCommerce sites. Hopefully, someone finds this post useful.