Your sites Log in Sign up Menu

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?


5 months ago, 1 replies   developers   seo   sitemap   Improve this 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 5 months ago ยท Improve this answer