The simplest description of a Sitemap is a file that list all the URL’s on a site for a Search Engine to crawl. Traditionally web crawlers would follow links on pages within a site and rely on them to discover new pages and index them. Sitemaps add a layer of intelligence to this by providing a list of URL’s up front and also adding additional metadata such as when the page was last updates, how often it changes and how important the page is.
For more information on Sitemaps have a look at sitemaps.org
Introducing Sitemap XML for Sitecore
Out of the box Sitecore doesn’t provide any built in functionality for auto generating a sitemap, but a good module on the Sitecore Marketplace is Sitemap XML (https://marketplace.sitecore.net/en/Modules/Sitemap_XML.aspx). This module will generate a schema compliant sitemap file in the root of your site on each publish of the site.
There are a couple of issue you might experience when trying to use it:
Once you’ve installed the module and attempted a full site publish you will likely get an error like this…
Job started: Publish to 'web'|Items created: 0|Items deleted: 0|Items updated: 78|Items skipped: 15877|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.NullReferenceException: Object reference not set to an instance of an object. at Sitecore.Modules.SitemapXML.SitemapManager.BuildSiteMap(String sitename, String sitemapUrlNew) at Sitecore.Modules.SitemapXML.SitemapManager..ctor() at Sitecore.Modules.SitemapXML.SitemapHandler.RefreshSitemap(Object sender, EventArgs args) at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object parameters, EventResult result) at Sitecore.Events.Event.RaiseEvent(String eventName, Object parameters) at Sitecore.Publishing.Publisher.NotifyEnd() at Sitecore.Publishing.Publisher.Publish() --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object parameters) at (Object , Object ) at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at Sitecore.Jobs.Job.ThreadEntry(Object state)
Going by the comments on the Sitecore marketplace this happens to quite a lot of people and unfortunately the limited documentation for the module doesn't explain the cause.
When you install the module it will create a config file called SitemapXML.config within App_Config\Include. By default that config will have the following 2 lines:
<site name="website_1" filename="sitemap1.xml" serverUrl="www.site1domain.com" /> <site name="website_2" filename="sitemap2.xml" serverUrl="www.site2domain.com"/>
These websites don't exist which is what causes the error. So to fix simply change the name of your website and the URL can be left blank. e.g.
<site name="website" filename="sitemap.xml" serverUrl="" />
Multiple Server Setup
If you're Sitecore installation is using separate servers for content management and content delivery you'll notice that your only generating sitemaps on your content management server.
To set up your content delivery server to start generating the files update the event node in the config file from
and also make sure you have both the SitemapXML.dll file and config file on your content deliver server.