Previously, I’ve looked at some of the problems with the SitemapXML module for Sitecore. Well, here are another couple that have caught me a few times…
There are different versions of the SitemapXML.dll. It’s not dreadfully, obvious – but there are. Here’s what ILSpy shows for different versions:
Notice how they’re different? More on that later.
The Old version of the DLL always seems to suffix .aspx to the URLs. This seems to be a bug. ILSpy shows in the old version:
The highlighted ‘true’ parameter tells .GetItemUrl() to append the file extension. In the newer version of the dll, this has gone:
And the .GetItemUrl() function seems to default to false.
Thus, if you’re plagued by .aspx extensions in the sitemap.xml file, make sure you’re using the later version of this assembly. (Actually, this is a pretty old solution; I may have to rewrite this as a more recent version sometime).
Additional Settings. Lastly, the newer version of the SiteMapXML module has a few additional settings in it’s configuration that are worth knowing about.
<!-- For SEO purpose, we might want to lowercase the url.
Remove the below custom LinkProvider if we don't want to lowercase the url. -->
<!--For SEO purpose, we might want to replace space in url with hyphen.
Remove below encodeNameReplacements if we do not want to do so.
Note that if we replace space with hyphen in url then content item name should not have hyphen.
We can do so by either adjust InvalidItemNameChars settings (as below) or writing Item Name rule not to allow hyphen for item name if the item is content item.-->
<replace mode="on" find=" " replaceWith="-" />
<!--Ensure that the item name with hyphen is not allowed-->
That’ll handle issues with hyphens in the sitemap, and the LinkManager class is basically wrappered to always give lower case URLs.