Log in Sign up

How to add the last modified date to my sitemap?

I'd like to include the lastmod field in my sitemap – how should I go about adding this?


a year ago, 1 replies   developers   seo   sitemap   Edit question

You can use the formatUpdated function to add the lastmod field to your template's sitemap.xml file. The final result should look like:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
  <url>
    <loc>{{blogURL}}</loc> 
  </url>
  <url>
    <loc>{{blogURL}}/archives/</loc> 
  </url>
  {{#menu}}
  {{#isPage}}
  <url>
    <loc>{{blogURL}}{{url}}/</loc>
    <lastmod>{{#formatUpdated}}YYYY-MM-DD{{/formatUpdated}}</lastmod>
  </url>
  {{/isPage}}
  {{/menu}}    
  {{#allEntries}}  
  <url>
    <loc>{{blogURL}}{{url}}/</loc> 
    <lastmod>{{#formatUpdated}}YYYY-MM-DD{{/formatUpdated}}</lastmod>  </url>
  {{/allEntries}}  
</urlset>

I made this change to the sitemap included with the default templates, since I think it's a good idea!

Answered a year ago · Edit answer