fix(sitemap): only advertise hreflang locales with real translations #161
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
javascript
question
severity: high
severity: low
severity: medium
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
isyuricunha/website!161
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/sitemap-hreflang-partial-translations"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Follow-up to #160: the sitemap still advertised hreflang variants for locales that have no translation of a given post.
Evidence / Reproduction
The pt-only post
coisas-que-eu-gostaria-que-tivessem-me-dito-quando-entrei-na-faculdade-de-ti(exists in pt, es, ja, zh-CN, fr, de — not en) had a sitemap cluster announcing:hreflang="en"->https://yuricunha.com/blog/coisas-...(404, confirmed by curl)x-default-> same 404 URLRoot cause
build_absolute_language_alternates({ slug })was called without the real translation set, so it always expanded toi18n.locales— including locales where the post does not exist.Fix
addLocalizedEntryacceptslocales: the actual translation set of the entry.postLocalesBySlug,projectLocalesBySlug, etc.).x-defaultfalls back to the first available locale when the default locale has no translation (instead of pointing at a 404).Tests
seo-alternates.test.ts: partial-translation set never advertises a missing locale;x-defaultpoints at an existing variant.sitemap.test.ts: clusters reflect the real translation set.Validation
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment