fix(sitemap): guard catalog-only rebuilds from wiping /tutorials/ URLs - #2126
Merged
Conversation
/sitemap.xml is served from the HANA page-sitemap.xml blob and republished by publish-content.ts on every non-slug rebuild (discoverPageFiles, gated `if (!opts.slug)`). catalog-only skips "Fetch tutorials", so Hugo bakes a sitemap with NO /tutorials/ URLs and republishing it WIPES the live sitemap down to ~180 links (reported 2026-09-03 by the Intelligent Search Data Crawling team: crawled docs ~1700 -> ~1500). Same wipe class as the /browse/ and /authors/ catalog-only wipes. - scripts/seed-sitemap-from-deployed.ts: catalog-only preserve step. Runs AFTER the Hugo build (the sitemap is a build output, not an input) and overwrites the tutorial-less sitemap with the one the approuter is currently serving. Fails the run if the deployed sitemap is unreadable or names zero tutorials (ALLOW_EMPTY_SITEMAP=1 escape hatch for seed envs). - scripts/check-sitemap-tutorials.cjs: fail-closed guard. Runs in full + catalog-only before publish; fails if the baked sitemap has zero /tutorials/ <loc> (the exact wipe signature). - rebuild-content.yml: wire both steps in after "Build Hugo site". - seo-files.test.js: smoke assertion that /sitemap.xml contains /tutorials/. - unit tests cover both tutorial-<loc> counters (shared logic, run through both impls so they can't diverge).
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.
Problem
The Intelligent Search Data Crawling team reported (2026-09-03) their Developers crawler started failing after Aug 6: crawled docs dropped from ~1,700 to ~1,500 and the live sitemap held only ~180 links.
Root cause:
/sitemap.xmlis served from the HANApage-sitemap.xmlblob (srv/lib/page-key-map.js).publish-content.tsrepublishes thatpage-*blob on every non-slug rebuild (discoverPageFiles, gatedif (!opts.slug)).<urlset>, republishes the good sitemap. Safe.hugo/content/tutorialsis empty, Hugo bakes a sitemap with no/tutorials/URLs, and republishing that tutorial-less blob wipes the live sitemap to ~180 links.Same wipe class as the
/browse/(2026-08-07) and/authors/(#1659 Phase C) catalog-only wipes.Changes
scripts/seed-sitemap-from-deployed.ts— catalog-only preserve step, mirroringseed-browse/seed-authors. Runs after the Hugo build (the sitemap is a build output, not an input) and overwrites the tutorial-less sitemap with the one the approuter is currently serving. Fails the run if the deployed sitemap is unreadable or names zero tutorials (ALLOW_EMPTY_SITEMAP=1escape hatch for seed envs).scripts/check-sitemap-tutorials.cjs— fail-closed guard, mirroringcheck-verb-shelves. Runs in full + catalog-only, before publish; fails if the baked sitemap has zero/tutorials/<loc>(the exact wipe signature)..github/workflows/rebuild-content.yml— wire both steps in after "Build Hugo site".test/smoke/seo-files.test.js— smoke assertion that/sitemap.xmlcontains a/tutorials/<loc>.scripts/__tests__/check-sitemap-tutorials.test.ts— 12 cases covering both tutorial-<loc>counters (shared logic run through both impls so they can't diverge).Verification
vitest run --project unit scripts/__tests__/check-sitemap-tutorials.test.ts→ 12/12 pass.