Skip to content

site: omit lastmod from sitemap entries without a date - #26365

Closed
foxythefoxer wants to merge 1 commit into
docker:mainfrom
foxythefoxer:fix/sitemap-zero-lastmod
Closed

foxythefoxer wants to merge 1 commit into
docker:mainfrom
foxythefoxer:fix/sitemap-zero-lastmod

Conversation

@foxythefoxer

Copy link
Copy Markdown

Description

The site's sitemap lists 1,003 pages as last modified on 0001-01-01. For example, here's the entry for docker container run:

<url>
  <loc>https://docs.docker.com/reference/cli/docker/container/run/</loc>
  <lastmod>0001-01-01</lastmod>
  ...
</url>

Every affected page is generated rather than written in Markdown: the docker and sbx CLI references, and the Sandboxes, Hub, DVP, AI Governance, and Registry API references. Anything that reads the sitemap takes that date at face value, so these pages look like they never change.

The date is zero because these pages are built by Hugo content adapters, such as content/reference/cli/_content.gotmpl, so they have no file of their own in git. With enableGitInfo: true, Hugo takes Lastmod from the last commit that touched a page's file. With no file, and no date set by the adapter, Lastmod stays at Go's zero time, and layouts/sitemap.xml prints it as is.

This change skips <lastmod> when Lastmod is zero, which is what Hugo's embedded sitemap template does in v0.163.0, the version this repo pins. The element is optional in the sitemap protocol.

I tested this with a local production build (HUGO_ENV=production docker buildx bake release), before and after the change:

Before After
<url> entries 2,203 2,203
<lastmod>0001-01-01</lastmod> 1,003 0
<lastmod> with a real date 1,200 1,200

Before the change, my local build produced exactly the same sitemap as docs.docker.com, byte for byte, so the build is a faithful stand-in for the live site. Comparing the two builds, the only difference is that the 1,003 zero-date <lastmod> elements are gone. Every other entry is unchanged, including all 1,200 real dates. docker buildx bake validate passes.

Related issues or tickets

None.

Reviews

  • Technical review

AI disclosure: Claude (Opus 5.5) helped with the diagnosis, the fix, this description and the tests. I reviewed everything before submitting.

Pages generated by content adapters (the docker and sbx CLI references
and the API references) have no file in git, so with enableGitInfo
their Lastmod is the zero time. The sitemap template printed it
unconditionally, giving 1,003 entries <lastmod>0001-01-01</lastmod>.

Skip the element when Lastmod is zero, as Hugo's embedded sitemap
template does. <lastmod> is optional in the sitemap protocol.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 41cc6d8
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/6ad18ec3953443e0ee1acea0
😎 Deploy Preview https://deploy-preview-26365--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the hugo Updates related to hugo label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hugo Updates related to hugo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants