Skip to content

fix(docs): send guessed section and /en addresses to a real page - #3769

Merged
yannickmonney merged 7 commits into
mainfrom
fix/docs-section-redirects
Sep 29, 2026
Merged

yannickmonney merged 7 commits into
mainfrom
fix/docs-section-redirects

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Guessed docs addresses now reach canonical content. Section folders such as /platform/automations redirect to the first navigation page beneath them. Their .md exports follow too (/de/platform/automations.md goes to /de/platform/automations/concepts.md), and so do the .md exports of moved pages. /en aliases resolve to the English root tree, and localized llms.txt / llms-full.txt aliases resolve to the shared root indexes. Explicit moves in docs/redirects.json still win. Locale prefixes and query strings are preserved, and moved and derived folders get prerendered redirect stubs. The marketing story and the docs issue template now link to pages that exist.

An /en/<page> redirect also pins the English locale cookie (tale_locale=en, Cache-Control: no-cache). Before this, the unprefixed target was negotiated again, and a reader with a German cookie or a German Accept-Language was sent on to /de/<page>, so the one address that names English landed on the German tree. Locale-neutral targets (llms.txt, .md) get no cookie.

Locale removal also refuses malformed paths that would become an external Location: /en//outside.invalid/page now answers the local 404. Docs reuses the shared locale-prefix remover with an English-only selection. Its existing DE/FR default also protects single-tree sites such as UI docs. Percent-encoded separators stay encoded and same-origin. Normal locale routing is unchanged.

The derived folder map reads the existing flattenNav() walker, and every slug-to-URL mapping goes through docPath and one exported slugRoute helper, so there is no second nav walker. The contributor contracts now describe the derived redirects: docs/AGENTS.md, the services/docs README, and the tests/AGENTS.md rule catalogue with the three new section-folder-* / derived-redirect-shadows-page rules. They also note that reordering nav.json changes where a folder URL lands.

Out of scope, noted as follow-ups: /legal (a folder on disk that is off the navigation, holding only noindex pages) still answers 404. The derived map covers folders under nav.json pages only.

Checklist

  • bun run check passes: not run locally. CI on this head is the gate. The scoped checks listed below pass.
  • bun run lint:sast passes: the Opengrep hook ran on every staged file in each commit.
  • Translations: N/A. No message keys changed.
  • Docs in docs/{en,de,fr}/: N/A. No end-user page content changed. The contributor contract docs/AGENTS.md is updated.
  • README.md / README.de.md / README.fr.md: N/A. Only the services/docs README row changed.

Test plan

At the current head:

  • services/docs vitest: 200 tests in 36 files. This includes redirects.test.ts (every section folder resolves in every locale, no chains, no shadowing, .md exports of moved pages and folders follow them, including behind /en) and the new redirect-route.test.ts. That test covers the mount prefix and query being kept, an /en page alias setting tale_locale=en with Domain/Secure, a control case showing that a German cookie plus Accept-Language negotiates to /de without the pin, and no cookie for /en/llms.txt.
  • packages/ui server and i18n vitest: 131 tests. @tale/docs and @tale/ui typecheck pass, as do workspace oxlint --type-aware, oxfmt --check, bun run lint:manual, and check-guide.ts on navigation.md. bun build server.ts bundles. Under the Bun runtime, lib/redirects.ts still expands to 228 redirect pairs.
  • Real Bun server (startReactServer plus the new redirect route, temporary dist). /en/platform/workspace/skills with Cookie: tale_locale=de and Accept-Language: de answered 301 with Set-Cookie: tale_locale=en. Following it with the cookie jar answered 200 with the English page. Without the pin, the same request answered 302 to /de/platform/workspace/skills. /de/platform/automations.md answered 301 to /de/platform/automations/concepts.md.
  • Manual: NAV-F16 now includes the .md guess. The new NAV-F17 covers the browser round trip: a German browser that opens /en/... stays on English.

At the previous head, before the review fixes (the redirect set is unchanged; 228 pairs, re-counted above):

  • The built docs site was checked at / and /docs/ (behind a prefix-stripping local proxy): 427 routes, 228 stubs, and every mapped redirect over GET and HEAD at both mounts. Real Chromium ran 26 cases in EN/DE/FR at 390px and 1280px, and the prerender SEO suite passed 9/9 at each mount.

Not verified: a full site rebuild at this head (disk is nearly full on the verification machine), the .md redirects against a built dist-seo, and a deployed production proxy.

People and language models guess docs addresses by trimming a page URL or
by assuming an English prefix. The folders above pages (/platform/automations,
/de/platform/admin/governance, /develop, …) have no page of their own, English
lives at the root, and llms.txt exists once for every locale, so all of those
guesses answered 404 even though every linked page resolves.

Section folders now redirect to the first page under them in nav.json order,
derived from the navigation rather than hand-maintained, with redirects.json
taking precedence. An /en prefix and a locale-prefixed llms.txt or
llms-full.txt resolve to the unprefixed address, landing on the final page in
one hop. The prerender writes meta-refresh stubs for the derived folders like
it does for moved pages. The tests guard that every section folder resolves in
every locale, that no derived entry shadows a page on disk, and that no target
chains into another redirect.
The feature story linked /agents and /quickstart on docs.tale.dev and the
docs issue template suggested docs/getting-started.md and tale.dev/docs/setup;
none of those exist. They now name the agents concepts page and the quickstart.
The redirect map carried its own nav.json walker and two copies of the
slug-to-route collapse, next to flattenNav in lib/content/nav.ts and
docPath in lib/content/paths.ts. Two walkers over the same file can
drift, so the derived section folders now read flattenNav and every
slug-to-URL mapping goes through one exported slugRoute helper.

paths.ts imports site-url relatively, because the Bun-run server and
prerender script now load it and Bun does not resolve the root
tsconfig's configDir paths.
Language models are pointed at the per-page Markdown exports, and they
guess those the same way readers guess section folders. A folder or a
moved page answered its HTML address with a 301 but its .md twin with a
404. The redirect lookup now maps /<source>.md to /<target>.md through
the shared md-paths helpers, including behind an /en prefix.
/en/<page> answered a bare 301 to the unprefixed page, which the server
then negotiates again. A reader with a German or French locale cookie,
or no cookie and a German Accept-Language, was sent on to /de/<page>, so
the one address that names English landed on the German tree.

The redirect now pins the English locale cookie (Cache-Control no-cache,
so a browser does not reuse it without the cookie), exactly as a /de or
/fr prefix refreshes its own. Locale-neutral targets such as llms.txt
and .md exports get no cookie. The route moves into lib/redirect-route.ts
so it is unit-tested, and @tale/ui/server exports isSecureRequest for its
Secure flag. NAV-F17 covers the browser round trip.
The contributor contracts described redirects as coming only from
docs/redirects.json. Section folders without a page now redirect to
their first page in nav.json, so reordering nav.json moves that target,
and the redirects suite gained three rules with their own fixes. The
docs contract, the service README and the test-suite catalogue say so.
@yannickmonney
yannickmonney merged commit f15ab74 into main Sep 29, 2026
49 checks passed
@yannickmonney
yannickmonney deleted the fix/docs-section-redirects branch September 29, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant