0

We have a custom Sitemap generator class for our site; as we want to control some of the URLs generated in our sitemap.xml for bucketed items. I believe I've patched the Sitemap Generator correctly in the config files:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <services>
      <register patch:instead="register[@serviceType='Sitecore.XA.Feature.SiteMetadata.Sitemap.ISitemapGenerator, Sitecore.XA.Feature.SiteMetadata']" serviceType="Sitecore.XA.Feature.SiteMetadata.Sitemap.ISitemapGenerator, Sitecore.XA.Feature.SiteMetadata"  implementationType="Sitecore.XA.Feature.SiteMetadata.Sitemap.CustomSitemapGenerator, XA.SiteMetaData.Custom" lifetime="Transient"/>
    </services>
  </sitecore>
</configuration>

However, I can't seem to trigger regeneration of the sitemap xml file; as it never seems to call our custom generator. I've tried rebuilding the code, reloading sitemap.xml, and republishing everything. Still won't trigger. I've verified the config file has been published to my build directory and is in the compiled Sitecore configuration XML.

How can I get the sitemap.xml to be regenerated for the site?

| improve this question | | | | |
  • you are able to view the output of /sitemap.xml on your browser ? – Abhay Dhar Jan 7 at 6:33
  • try app pool reset once. – Abhay Dhar Jan 7 at 6:34
0

SitemapHandler which internally is using ISitemapGenerator is the entry point. It has a virtual GetSitemap method which is looking for an instance of ISitemapGenerator in the DI container. So it should pick up your implementation if you have correctly replaced an instance of ISitemapGenerator in the container. If the above config patch is not working for you try this approach: https://stackoverflow.com/questions/43590769/replace-service-registration-in-asp-net-core-built-in-di-container.

One more thing. The SitemapHandler can cache generated sitemap in memory (HttpRuntime.Cache) or in the file. It depends on the settings (I believe those options are defined on the Settings item in your site). Check if the sitemap is not already generated and is stored in the file.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.