Repository navigation
site: omit lastmod from sitemap entries without a date - #26365
Closed
foxythefoxer wants to merge 1 commit into
Closed
foxythefoxer wants to merge 1 commit into
foxythefoxer wants to merge 1 commit into
Conversation
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>
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The site's sitemap lists 1,003 pages as last modified on
0001-01-01. For example, here's the entry fordocker container run:Every affected page is generated rather than written in Markdown: the
dockerandsbxCLI 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. WithenableGitInfo: true, Hugo takesLastmodfrom the last commit that touched a page's file. With no file, and no date set by the adapter,Lastmodstays at Go's zero time, andlayouts/sitemap.xmlprints it as is.This change skips
<lastmod>whenLastmodis 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:<url>entries<lastmod>0001-01-01</lastmod><lastmod>with a real dateBefore 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 validatepasses.Related issues or tickets
None.
Reviews
AI disclosure: Claude (Opus 5.5) helped with the diagnosis, the fix, this description and the tests. I reviewed everything before submitting.