Repository navigation
fix(seo): generate sitemap.xml from routes at build time with git-derived lastmod - #13
Merged
Merged
Conversation
The sitemap shipped to production lived at demo/public/sitemap.xml and listed only 9 URLs. router/routes.ts had grown to 16 public routes, so the 7 most recently added marketing guides — react-pivot-table-no-watermark, vue-pivot-table-free, react-datagrid-csv-export, vue-datagrid-filter-sort-search, react-datagrid-calculated-fields, vue-datagrid-column-resize and nextjs-datagrid-pivot-table — were prerendered and live but never submitted to search engines. A second, more complete sitemap existed at demo/sitemap.xml, but Vite's root is `demo` and publicDir therefore resolves to demo/public, so that file was never copied into the build output. demo/robots.txt was a dead duplicate of demo/public/robots.txt for the same reason. Generate the sitemap in scripts/prerender.mjs from the same ROUTES list that drives prerendering, so a newly added guide is always listed, and delete the three stale/dead static files. Verified: build:demo emits dist-demo/sitemap.xml with all 16 URLs.
Stamping every URL with the build date meant all 16 <lastmod> values bumped on every deploy, including pages unchanged for months — the kind of always-wrong freshness signal that teaches crawlers to distrust the sitemap's dates entirely. Date each route from the last commit touching its content files (Home.vue for /, VsAgGrid.vue for the comparison page, MarketingGuide.vue + router/routes.ts for guide pages), and omit the optional <lastmod> tag when git can't answer (no repo, or a shallow CI clone whose truncated history contains no commit for those files). Verified: build:demo now emits per-route dates (e.g. /vs-ag-grid at its June commit date) that hold stable across rebuilds.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Summary
The sitemap shipped to production (
demo/public/sitemap.xml) listed only 9 URLs whilerouter/routes.tsdefined 16 public routes — the 7 newest marketing guides were live and prerendered but never submitted to search engines. A complete 16-URL sitemap existed atdemo/sitemap.xml, but Vite's root isdemo, sopublicDirresolves todemo/publicand that file never shipped;demo/robots.txtwas a dead duplicate for the same reason.Changes
scripts/prerender.mjsnow generatesdist-demo/sitemap.xmlfrom the same route list that drives prerendering, so a newly added guide can never go unlisted again<lastmod>is derived from the last git commit touching each route's content files (not the build date, which would bump all 16 dates on every deploy and erode crawler trust in the sitemap); the optional tag is omitted when git can't answer, e.g. on a shallow CI clonedemo/public/sitemap.xml,demo/sitemap.xml,demo/robots.txtVerification
pnpm build:demoemitsdist-demo/sitemap.xmlwith all 16 URLs/vs-ag-gridkeeps its June commit date) and stable across rebuildspnpm lintclean;demo/public/robots.txt(the served copy) still points at/sitemap.xmlGenerated by Claude Code