Question: Howto add real last modified date in sitemap.xml

Hi all!

I wonder if you could help me out here with the questions below.

We have an internal NuGet package for exposing the sitemap.xml in a generic way (based on given Reusable field schema(s)). It displays everything with their alternate url's, a snippet here:

  <url>
    <loc>https://test.xbyk.local:44395/en/departments</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://test.xbyk.local:44395/en/departments" />
    <xhtml:link rel="alternate" hreflang="nl" href="https://test.xbyk.local:44395/afdelingen" />
    <lastmod>2026-06-19T18:38:12+02:00</lastmod>
  </url>

One thing that hasn't been done yet is adding the true lastmod. Since most pages are also build up using contentitems (selected on page and/or widgets) quite often the lastmod date is not the actual lastmod date, because a contentitem on it has changed.
We need this true date because of external access, and google of course.

Question: Has anyone resolved this issue already? Or might Kentico be working on this (is it on any roadmap?)

Trying to retrieve the true last modified date during generating the sitemap.xml is not an option. For thousands of pages that would be to slow and heavy. I thought I might solve it in the the following way:

  1. Create a Custom Module and Data Class
  • Create a custom module in Xperience by Kentico.

  • Within this module, create a data class (e.g., PageContentLastModified) with fields like WebPageItemID and ContentLastModified (datetime).

  1. Update the Value via Event Handlers
  • Implement an event handler that triggers when a related content item is published.

  • In this handler, retrieve all related pages using this contentitem (recursively, if needed).

  • Store this date in your custom module table for the corresponding WebPageItemID.

  1. Use This Value in Your sitemap.xml
  • When generating the sitemap.xml, read the last content modification date from your custom module table and use the latest date: page or content.

  • If no value is stored, fall back to the page’s standard LastModified date. Initially this date is good anyways, until there is something changed.

Question: Anybody any idea's on this? Good/bad or a better suggestion?


Answers

To response this discussion, you have to login first.