Problems with SitemapXML module for Sitecore

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:

Decompiled

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:

Old

The highlighted ‘true’ parameter tells .GetItemUrl() to append the file extension. In the newer version of the dll, this has gone:

New

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. -->
<linkManager>
<providers>
<add name="sitecore">
<patch:attribute name="type">Sitemap.XML.Links.LowerCaseLinkProvider,Sitemap.XML</patch:attribute>
<patch:attribute name="addAspxExtension">false</patch:attribute>
<patch:attribute name="languageEmbedding">never</patch:attribute>
</add>
</providers>
</linkManager>

<!--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.-->
<encodeNameReplacements>
<replace mode="on" find=" " replaceWith="-" />
</encodeNameReplacements>

<settings>
<!--Ensure that the item name with hyphen is not allowed-->
<setting name="InvalidItemNameChars">
<patch:attribute name="value">\/:?&quot;&lt;&gt;|[]-</patch:attribute>
</setting>
</settings>

That’ll handle issues with hyphens in the sitemap, and the LinkManager class is basically wrappered to always give lower case URLs.

Advertisement
Problems with SitemapXML module for Sitecore

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.