[Hugo] Sitemap Index with Last Modified Dates

wahyu setyanto 5ebLtV0PKpU unsplash scaled
Genx Avatar
Share This:

In Hugo (and most modern static site generators), the value of .Lastmod (which you use for <lastmod> in your sitemap) is determined as follows, in this priority order:

  1. Front Matter lastmod: If you have a lastmod parameter in your content’s front matter, Hugo uses this date.
  2. Front Matter date: If lastmod is not set, Hugo will fall back to the date parameter in front matter.
  3. Git Info or File Mod Time (if enabled):
  • If you enable enableGitInfo = true in your Hugo config, Hugo can use the latest Git commit date for the page or section as lastmod.
  • If not using Git, Hugo may use the file’s last modification time on disk.

So, in the context of your sitemap:

  • The <lastmod> value will show the date in lastmod front matter if present.
  • If lastmod is missing, it will fall back to date in the front matter.
  • If neither is present, and Hugo is configured for Git info, it uses the last Git commit date.
  • Otherwise, it may use the file’s last filesystem modification date.

Summary:

The last modified date in your sitemap is either the explicit lastmod in your page’s front matter, or (if missing) the next available source based on Hugo’s logic described above. For accurate sitemap dates, always set lastmod front matter for your pages/sections.

Related Posts

Genx

in

Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

sixteen + seventeen =

Webmention: Have you posted a response to this article? Let me know the URL: