fix(docs): CLI guide relative links resolve correctly#2505
Conversation
Links in non-index command-line-tools/ pages used `href="./<sibling>/"` and `[Text](./<sibling>/)`. Per RFC 3986, relative refs resolve against the base URL by stripping everything after the last `/`, so on a page served at `/v4-0-0-snapshot/command-line-tools/installation/`, `./quick-start/` becomes `/v4-0-0-snapshot/command-line-tools/installation/quick-start/` — a 404. Only `command-line-tools/index.mdx` (URL ends with the section dir itself) gets the right resolution from `./`. Switch every non-index page in `command-line-tools/` and its sub-folders to `../<sibling>/` for both LinkCard `href` and inline markdown links. The wheels-commands/* and core-commands/* depths inherit the same fix. Resolves #2424. Resolves #2426.
| /> | ||
| <LinkCard | ||
| title="Creating a Project" | ||
| href="./creating-a-project/" | ||
| href="../creating-a-project/" |
There was a problem hiding this comment.
🔴 The Quick Start LinkCard href="../quick-start/" here resolves to /v4-0-0-snapshot/command-line-tools/wheels-commands/quick-start/, which 404s — quick-start.mdx lives one directory higher, not in wheels-commands/. The PR sed only rewrote ./ → ../, so cards that were already ../ (here and in creating-a-project.mdx:171) were not touched and remain broken. Fix by changing both to ../../quick-start/, matching the pattern already used correctly in wheels-commands/dev-server.mdx:134 and wheels-commands/app-inspection.mdx:267.
Extended reasoning...
What the bug is
In wheels-commands/code-generation.mdx (the <CardGrid> block this PR edits), the Quick Start LinkCard at line 422-425 keeps its pre-PR href="../quick-start/":
<LinkCard
title="Quick Start"
href="../quick-start/"
description="End-to-end walkthrough from wheels new to a running CRUD resource."
/>The same defect exists in wheels-commands/creating-a-project.mdx at line 171 — also a Quick Start LinkCard inside a CardGrid this PR edits, also still href="../quick-start/".
Why this 404s — a step-by-step proof
- The page lives at
web/sites/guides/src/content/docs/v4-0-0-snapshot/command-line-tools/wheels-commands/code-generation.mdx. - Astro/Starlight serves it at
/v4-0-0-snapshot/command-line-tools/wheels-commands/code-generation/. - Per RFC 3986 §5.3, the base for relative-ref resolution is everything up to and including the last
/of the page path:/v4-0-0-snapshot/command-line-tools/wheels-commands/code-generation/. - Resolving
../quick-start/against that base strips one segment (code-generation/) and appendsquick-start/, giving/v4-0-0-snapshot/command-line-tools/wheels-commands/quick-start/. ls web/sites/guides/src/content/docs/v4-0-0-snapshot/command-line-tools/wheels-commands/— verified — contains noquick-start.mdx. The actual file is atcommand-line-tools/quick-start.mdx, served at/v4-0-0-snapshot/command-line-tools/quick-start/.- Result: 404. The same calculation applies verbatim to
creating-a-project.mdx.
Why the PR did not catch it
The PR applied a uniform sed -i -E s|href="\./|href="../|g (per the description). That transform only converts links that started with ./. The two Quick Start cards were already at ../quick-start/ before the PR (the diff itself confirms this — only "Creating a Project", "Database", and "Scaffold Cleanup" cards changed in code-generation.mdx). They were broken before and they are still broken after, even though both files appear in the PRs explicit list of files where Related Commands cards were 404ing.
What "right" looks like
The correct relative ref from a wheels-commands/<page>/ URL up to command-line-tools/quick-start/ requires popping two segments: ../../quick-start/. That is exactly the pattern wheels-commands/dev-server.mdx:134 already uses correctly (verified: grep returns 134: href="../../quick-start/"), and wheels-commands/app-inspection.mdx:267 uses the same ../../configuration/ pattern for its parent-dir cross-link.
Fix
Two single-character edits:
wheels-commands/code-generation.mdx:424—href="../quick-start/"→href="../../quick-start/"wheels-commands/creating-a-project.mdx:171—href="../quick-start/"→href="../../quick-start/"
Impact
The PR title is "fix(docs): CLI guide relative links resolve correctly" and the test plan checks that all Related Commands cards resolve. After this PR merges as-is, two cards on two pages explicitly named in the PR description still 404. Catching exactly this is the point of the change.
Summary
Resolves #2424. Resolves #2426.
The "Related Commands" / "What's next" CardGrids and inline markdown links across multiple
v4-0-0-snapshot/command-line-tools/pages all resolved to 404. Affected pages:command-line-tools/installation.mdxcommand-line-tools/quick-start.mdxcommand-line-tools/configuration.mdxcommand-line-tools/mcp-integration.mdxcommand-line-tools/wheels-commands/app-inspection.mdxcommand-line-tools/wheels-commands/code-generation.mdxcommand-line-tools/wheels-commands/creating-a-project.mdxRoot cause
Links used
href="./<sibling>/"and[Text](./<sibling>/). Per RFC 3986, relative refs resolve against the base URL by stripping everything after the last/. For a page served at/v4-0-0-snapshot/command-line-tools/installation/, the base path is/v4-0-0-snapshot/command-line-tools/installation/— and./quick-start/resolves to/v4-0-0-snapshot/command-line-tools/installation/quick-start/, which 404s.command-line-tools/index.mdxwas the one page where./worked, because Astro serves it at/command-line-tools/(URL ends in the section dir itself), so./quick-start/lands at/command-line-tools/quick-start/.Fix
Switched every non-index page in
command-line-tools/and itswheels-commands//core-commands/sub-folders to../<sibling>/for bothLinkCardhrefprops and inline markdown links. Same transform applied uniformly via sed:command-line-tools/index.mdxwas deliberately excluded — its./links work and don't need to change.Test plan
/quick-start/,/configuration/,/mcp-integration/— all "What's next" / "Related Commands" cards resolve./wheels-commands/app-inspection/, click "Related Commands" — resolves.Generated by Claude Code