Repository navigation
Drop 404 hreflang alternates on English-only pages - #1987
Merged
David Pine (IEvangelist) merged 1 commit intoOct 30, 2026
Merged
Conversation
Starlight emits an hreflang alternate for every configured locale, but the custom StarlightPage routes under /hub/, /reference/api/ and /reference/samples/<sample>/ are only generated for the default locale, so alternates such as /de/hub/ point at 404 pages. Remove the hreflang alternates for those routes in the route-data middleware. Co-authored-by: Copilot <[email protected]>
Contributor
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
David Fowler (davidfowl)
marked this pull request as ready for review
October 30, 2026 06:23
David Fowler (davidfowl)
requested a review
from David Pine (IEvangelist)
as a code owner
October 30, 2026 06:24
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change removing hreflang alternates from English-only pages.
No open issues 🎉
What changed in this PR
This PR removes hreflang alternates that point to nonexistent localized versions of English-only pages on aspire.dev.
Changes:
- Adds a route helper identifying Developer Hub, API reference, and individual sample pages as English-only.
- Filters locale alternates from those pages while preserving canonical links and other head entries.
- Adds regression tests confirming English-only routes lose alternates and localized documentation routes retain them.
| File | Description |
|---|---|
src/frontend/tests/unit/route-data-middleware-hreflang.vitest.test.ts |
Tests route matching, alternate removal, and preservation of other links. |
src/frontend/src/utils/default-locale-only-routes.ts |
Identifies English-only custom routes. |
src/frontend/src/route-data-middleware.ts |
Removes hreflang alternates for matching routes. |
Review effort: Balanced
This was referenced Oct 30, 2026
David Pine (IEvangelist)
approved these changes
Oct 30, 2026
David Pine (IEvangelist)
deleted the
aspireagent/fix-english-only-hreflang
branch
October 30, 2026 13:00
David Pine (IEvangelist)
pushed a commit
that referenced
this pull request
Nov 1, 2026
## Summary On Developer Hub and sample pages, choosing a language in the footer language picker sends readers to a 404. Those pages are generated only in English, but the picker adds a locale prefix to the URL anyway: | Page | Pick "Deutsch" → | Status | | --- | --- | --- | | `/hub/` | `/de/hub/` | 404 | | `/hub/glossary/apphost/` | `/de/hub/glossary/apphost/` | 404 | | `/reference/samples/aspire-shop/` | `/de/reference/samples/aspire-shop/` | 404 | | `/reference/api/csharp/` | `/reference/api/csharp/` | 200 (already special-cased) | | `/get-started/install-cli/` | `/de/get-started/install-cli/` | 200 (translated docs, unchanged) | I reproduced this with Playwright against `astro dev` at `main` 04ecd1c, and production returns the same 404s for those URLs. **Root cause:** `FooterPreferences.astro` only recognised API reference pages as English-only, using `isApiReferencePath`. Every other path got a locale prefix. **Fix:** - The picker's path decision moves into `src/utils/language-switch.ts` (`getLanguageSwitchPath` and `getSelectedLocaleForPath`). - Every default-locale-only route (`/hub/**`, `/reference/api/**` and `/reference/samples/<sample>/`) now gets the existing API reference behaviour: store the preferred locale, stay on the English URL, and show the stored preference in the picker. - Translated docs routes behave as before. `src/utils/default-locale-only-routes.ts` is byte-identical to the file added in #1987 (same git blob, `dd363d05`). These two PRs merge cleanly in either order and don't depend on each other. ## Third-party links and affiliations None. ## Validation - **New unit test** `tests/unit/language-switch.vitest.test.ts`: - Before the fix, the existing logic was extracted unchanged into the new helpers and 7 of the 17 tests failed. All of the failures were on hub and sample routes. The API reference and docs cases passed, which shows the extraction itself didn't change behaviour. - After the fix: 17 of 17 pass. - **New browser test** in `tests/e2e/ui-regressions.spec.ts` ("language selector keeps English-only pages on their English URL"). It picks Deutsch through the real listbox on `/hub/` and `/reference/samples/aspire-shop/`. - Before the fix it failed on desktop-chromium and mobile-chromium with `Expected: "/hub/" Received: "/de/hub/"`. - After the fix it passes on both. - It ran together with the existing footer and language-selector tests: 9 of 9 passed on `astro dev`. - **Full unit suite** (`vitest run`): 83 files, 1125 passed and 1 skipped. - **Lint** (`astro sync`, skill digest check, `eslint . --max-warnings 0`) and **Prettier** on the changed files: both pass. - **`tsc`:** no new errors. The one `.astro` import resolution error in `custom-components.vitest.test.ts` is already on `main`. - This changes navigation, not styling, so there are no screenshots. **🤖 Posted by AspireAgent (AI Agent)** Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]>
David Pine (IEvangelist)
pushed a commit
that referenced
this pull request
Nov 3, 2026
## Summary The **Get started** sidebar has a Glossary entry (`link: '/hub/glossary/'` in `config/sidebar/docs.topics.ts`). Starlight adds the active locale to sidebar links, so every localized docs page links to `/de/hub/glossary/`, `/ja/hub/glossary/` and so on. The Hub is English-only and those pages aren't generated, so the link returns a 404. For example, https://aspire.dev/de/get-started/install-cli/ currently renders `href="/de/hub/glossary/"`, and `https://aspire.dev/de/hub/glossary/` returns **404**. `route-data-middleware.ts` already removes the locale from sidebar links to API reference pages. This PR extends that same sidebar pass: when a localized sidebar href resolves to a default-locale-only route (`isDefaultLocaleOnlyPath`, covering `/hub/**`, API reference and individual samples), the locale prefix is stripped. Links to translated docs pages keep their locale. `src/utils/default-locale-only-routes.ts` is byte-identical to the copy in #1987 and #1988, and the import is identical, so the PRs combine without conflicts. I trial-merged this branch with #1984, #1987 and #1988 locally: there were no conflicts and all 1143 unit tests passed on the combined tree. There is no visual change; only link targets change. ## Third-party links and affiliations None. ## Validation - New regression test `tests/unit/route-data-middleware-sidebar-locale.vitest.test.ts` (3 tests): - Before the fix: 1 failed (`/de/hub/glossary/`, `/ja/hub/`, `/zh-cn/reference/samples/aspire-shop/` stayed localized) and 2 passed (control cases). - After the fix: 3 of 3 pass. - Full unit suite (`vitest run --config vitest.config.ts`): 83 files, 1111 passed, 1 skipped. - Lint (`astro sync`, `compute-skill-digests --check`, `eslint . --max-warnings 0`) passes, and Prettier check passes on the changed files. - Rendered on `astro dev`: - `/de/get-started/install-cli/` and `/ja/fundamentals/telemetry/` now render only `href="/hub/glossary/"`. - `/de/get-started/resources/` remains localized. **🤖 Posted by AspireAgent (AI Agent)** --------- Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]>
Sébastien Ros (sebastienros)
added a commit
that referenced
this pull request
Nov 11, 2026
- TypeScript API parameter descriptions (#2009) - No locale prefix or hreflang alternates for English-only pages: the footer language picker (#1988), hreflang (#1987) and the sidebar Glossary link (#1989) - Footer link to the Aspire MIT license - Homepage: environment fade (#1993), stale AppHost animations (#1950), the dashboard carousel keeps the selected slide on activation - Search: first-result highlight with out-of-order renders (#2007), hover cursor flicker (#1977) - Live status over WebSocket (#1942) and twoslash hover, merged into the copies of the frontend scripts - Icon data 5.40.0 and the regenerated sprite - src/frontend now uses Bun: README and script usage updated
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.
Summary
Developer Hub, API reference and individual sample pages advertise
hreflangalternates for all 15 locales, but those pages exist only in English. The localized URLs return 404, so search engines get alternates that point to error pages.Live production (
main04ecd1c), checked withcurl:https://aspire.dev/hub/https://aspire.dev/de/hub/,/zh-cn/hub/https://aspire.dev/hub/glossary/apphost/https://aspire.dev/ja/hub/glossary/apphost/https://aspire.dev/reference/api/csharp/https://aspire.dev/de/reference/api/csharp/https://aspire.dev/reference/samples/aspire-shop/https://aspire.dev/de/reference/samples/aspire-shop/Docs content pages are fine:
/de/get-started/install-cli/and/de/reference/samples/return 200, either translated or as a fallback. The sitemap already lists the English-only pages without alternates, so only the page<head>was inconsistent.Root cause: Starlight's
getHead(@astrojs/starlight/utils/head.ts) adds an alternate for every configured locale whenever the site is multilingual. That includes the customsrc/pages/**routes rendered through<StarlightPage>, which are never generated per locale.route-data-middleware.tsalready documents that API reference pages exist only in the default locale.Fix:
isDefaultLocaleOnlyPathhelper insrc/utils/default-locale-only-routes.ts. It matches/hub/**,/reference/api/**(reusing the existing API reference pattern) and/reference/samples/<sample>/.link[rel=alternate][hreflang]head entries for those routes.Third-party links and affiliations
None.
Validation
tests/unit/route-data-middleware-hreflang.vitest.test.ts:expected [ 'en', 'da', 'de', … ] to deeply equal [])./,/get-started/install-cli/,/de/get-started/install-cli/,/reference/samples/) keep all 15 locale alternates plusx-default.astro dev, countinghreflangattributes:/hub/,/hub/glossary/apphost/,/reference/api/csharp/and/reference/samples/aspire-shop/: 0, down from 16 in production. Canonical is unchanged./get-started/install-cli/,/de/get-started/install-cli/and/reference/samples/: still 16.vitest run): 83 files, 1119 passed and 1 skipped.astro sync, skill digest check,eslint . --max-warnings 0), Prettier on the changed files, andtsc(no errors in the changed files): all pass.🤖 Posted by AspireAgent (AI Agent)