Sitemaps omit hreflang self/x-default alternates for untranslated entries on i18n sites #1776
khoinguyenpham04
announced in
Roadmap
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This Roadmap discussion mirrors #1522: Sitemaps omit hreflang self/x-default alternates for untranslated entries on i18n sites.
Use this discussion to upvote the roadmap item and discuss priority, use cases, and product feedback. Keep implementation tracking, reproduction details, and PR-specific feedback on the source issue.
bug,triage/failed,bot:bug,bot:failedOriginal Issue
Description
On an EmDash site with i18n enabled, generated collection sitemaps only emit <xhtml:link rel="alternate"> entries when a content item has more than one translated sibling.
For a published default-locale post with no localized versions, the generated sitemap currently emits:
Expected output when i18n is enabled:
This matters because Google’s hreflang sitemap guidance says each URL should list every language/locale variant, including itself. For single-locale entries on a multilingual site, the entry itself is still the locale-specific version and should be declared as such. x-default also gives crawlers a clear fallback URL.
References:
Steps to reproduce
en-usas the default locale and at least one non-default locale.{ "slug": "posts", "label": "Posts", "labelSingular": "Post", "urlPattern": "/{slug}/", "hasSeo": true, "supports": ["drafts", "revisions", "preview"] }Publish one default-locale post, for example locale
en-us, with no translated sibling entries.Request the generated collection sitemap, for example:
<url>entry only includes<loc>and<lastmod>, with no selfhreflangand nox-default.Environment
Logs / error output
No runtime error is thrown. The issue appears to come from the sitemap route logic.
In
src/astro/routes/sitemap-[collection].xml.ts, alternates are only written when there is more than one sibling:Ungrouped entries are emitted with
siblingsasnull:As a result, untranslated entries on i18n-enabled sites never get their locale self-reference or
x-defaultfallback in the sitemap.Beta Was this translation helpful? Give feedback.
All reactions