Skip to content

site: take sitemap dates from git, because mtime is a lie in CI - #7

Merged
ralyodio merged 1 commit into
mainfrom
site/sitemap-git-dates
Aug 30, 2026
Merged

site: take sitemap dates from git, because mtime is a lie in CI#7
ralyodio merged 1 commit into
mainfrom
site/sitemap-git-dates

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

The lastmod fix in #5 worked locally and did nothing in production. Deployed, all eighteen URLs still carried one identical date — 2026-08-30T04:07:33, the build's own checkout time.

Why

mtime was the wrong source. A git clone stamps every file it writes with the moment it wrote it, so on a CI checkout every file shares one mtime and the per-page dates collapse straight back into the single build timestamp the change existed to remove.

A working tree has real edit times. That is exactly why local verification passed and proved nothing — the one environment where mtime works is the one environment that never serves the sitemap.

Reproduced

Cloned the repo and compared both sources against the same thirteen files:

distinct mtimes:    1
distinct git dates: 6

Six rather than thirteen because several docs were committed together — the honest answer, since those pages did change at the same moment.

The fix

The date now comes from git log -1 --format=%cI -- <path>: a record of when the content changed, not when the machine last touched the file. mtime stays as a fallback for a build with no git history, where it is no worse than the build clock it replaces, and the build clock remains the last resort.

Verified against a build, not a working tree

Nine distinct dates across the eighteen URLs in .next/server/app/sitemap.xml.body.

Full suite 243 passing, typecheck clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y5jnkZKX4AdPgBMzMosxE7

The lastmod fix in #5 worked locally and did nothing in production. Deployed,
all eighteen URLs still carried one identical date -- 2026-08-30T04:07:33,
the build's own checkout time.

mtime was the wrong source. A git clone stamps every file it writes with the
moment it wrote it, so on a CI checkout every file in the tree shares one
mtime and the per-page dates collapse straight back into the single build
timestamp the change existed to remove. A working tree has real edit times,
which is exactly why local verification passed and proved nothing.

Reproduced by cloning the repository and comparing the two sources against the
same thirteen files:

  distinct mtimes:    1
  distinct git dates: 6

Six rather than thirteen because several docs were committed together, which
is the honest answer: those pages did change at the same moment.

So the date now comes from `git log -1 --format=%cI -- <path>`, which is a
record of when the content changed rather than when the machine last touched
the file. mtime stays as a fallback for a build with no git history, where it
is no worse than the build clock it replaces, and the build clock remains the
last resort.

Verified against a build rather than a working tree: nine distinct dates
across the eighteen URLs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5jnkZKX4AdPgBMzMosxE7
@ralyodio
ralyodio merged commit 0975cbd into main Aug 30, 2026
4 checks passed
@ralyodio
ralyodio deleted the site/sitemap-git-dates branch August 30, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant