Uh oh!
There was an error while loading. Please reload this page.
feat: add sitemap hreflang alternates for localized legal pages - #18
feat: add sitemap hreflang alternates for localized legal pages#18Addin wants to merge 1 commit into
Conversation
14c8782 to
377d367Compare377d367 to
1c645fcCompareAddin
commented
Aug 24, 2026
Rebased onto the sc-151 stack (stack #27: #25 → #26 → #21 → this) so the hreflang work composes with the entity-narrative changes. Conflicts resolved in |
There was a problem hiding this comment.
.please ignore this .playwright-mcp folder created on use the skill
There was a problem hiding this comment.
also remove this images that is not part of the code.
There was a problem hiding this comment.
is this code style part of the recent lint inclusion? if is possible can we make all this code styles part of another PR to not make this code hard to be reviewed?
nathanredblur
commented
Aug 26, 2026
if you can, add a small unit test to validate the main problem that we try to solve on not including @astrojs/sitemap |
Closes sc-142 (Add sitemap hreflang alternates for localized legal pages)
Note
Stacked on #12 (
fix/i18n-hreflang-all-pages). This branch is based on it; until #12 merges this PR shows both changesets. Once #12 lands inmain, the diff here shrinks to the two files below.Summary
Emit
<xhtml:link rel="alternate" hreflang="...">entries in the generated sitemap for the four localized legal pages, matching their<head>annotations exactly.Problem
@astrojs/sitemappairs hreflang alternates by stripping the locale prefix and grouping URLs with identical remaining paths. Legal slugs differ per locale (terminosvsterms,privacidadvsprivacy), so/en/terms/never paired with/terminos/and all four legal URLs shipped with zero sitemap alternates — while their<head>(viaLegal.astro) declared correct ones.Fix
src/lib/sitemap.ts: builds each legal page's alternate set from the existinglegalSlugsmap (single source of truth) plus the sharedHREFLANG/DEFAULT_LOCALEconsts, keyed by pathname.astro.config.mjs: wires it via the integration'sserializehook. Items that already have built-in links (homepages) and pages without counterparts pass through untouched.Before / after
Before:
https://cotrasoft.co/terminos/→ no alternates.After:
Verification
/about/,/blog/correctly have none (no English counterpart).<head>annotations in the built HTML.biome ci ./srcgreen (pre-push hook); remaining warnings are pre-existing (sc-144).