fix: only emit hreflang alternates for existing translations#284
Merged
Conversation
EN-only pages (e.g. api-reference/common-4xx-errors) emitted hreflang alternates for es/pt-BR/de in both the sitemap and the page head, pointing at localized URLs that 404. Semrush flagged 3 4xx pages plus incorrect hreflang, dropping International SEO. - scripts/generate-sitemap.mjs: filter alternates to locales whose content file exists (the url loop already skipped missing translations; the hreflang block did not). - app/[lang]/[[...mdxPath]]/page.tsx: same existence filter on the generateMetadata languages map. Fully-translated pages keep all 4 locales; EN-only pages list only en and x-default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Author
|
Merge gate (auto-classified): gate=smoke-passed — auto-classified by the gate-log enforcer (11min after merge, no Posted by |
Mlaz-code
added a commit
that referenced
this pull request
Jul 12, 2026
…285) (#286) The api-reference/common-4xx-errors page (added Jul 8) existed only in EN, leaving the three locale URLs 404 and each locale one page short of parity (57 vs 58). #284 already stopped the hreflang/switcher/sitemap from pointing at the missing URLs; this adds the translations themselves plus the sidebar _meta entries. JSON error bodies stay verbatim EN (they document literal API responses). Full build green: 232 pages / 4 languages indexed. Co-authored-by: sharp-resolver[bot] <3736210+sharp-resolver[bot]@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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
Semrush Site Audit (sharpapi.io campaign) flagged 3 new 4xx pages plus incorrect hreflang, dropping International SEO to 88% (-9) and Site Health to 95% (-4). Root cause: EN-only docs pages emit hreflang alternates for all 4 locales (es/pt-BR/de) that do not exist and 404.
Confirmed:
docs.sharpapi.io/{de,es,pt-BR}/api-reference/common-4xx-errors/returns 404docs.sharpapi.io/api-reference/common-4xx-errors/(en) returns 200Fix
Only emit hreflang alternates for locales that actually have the page translated (content file present):
Verified
🤖 Generated with Claude Code