Before you begin
- The new URL path decided before you change files, see Write → Where pages live for how file paths map to URLs
- Preview running locally when you want to confirm the new page and redirect
For how redirects behave in production, branch previews, vanity subdomains, and custom domains, see Redirects. Field syntax lives in Page frontmatter.
When you change a published URL, update three things: the file at the new path, the sidebar entry, and a redirect stub at the old path.
Serve content from the new URL
Rename or move the file under
docs/to match the new URL. For example, movedocs/installation.mdxtodocs/getting-started.mdxso the page serves at/getting-started.Point sidebar at the new href
Update the sidebar in
docs.jsonso the entry points at the newhref. Remove or replace the old path, readers should not land on a dead link from navigation. See Organize.Keep bookmarks working with a redirect stub
Create a redirect stub at the old file path (next section). Without it, bookmarks and external links to the old URL return 404 (which can negatively impact SEO rankings).
Keep the stub file at the old path even after the content lives elsewhere. Deleting the stub removes the old URL entirely — unless you forward it from the redirects map in docs.json (see Forward deleted pages in bulk).
Leave a minimal file at the old path and set redirect in frontmatter to the destination.
Keep a stub file at the old path
Create or replace the file at the old location, for example
docs/installation.mdxafter you moved content todocs/getting-started.mdx.Declare the destination in frontmatter
Set
redirectpointing at the new location:yaml--- redirect: /getting-started ---titleanddescriptionare not required. The body can be empty. docs.page readsredirectand returns a 307 Temporary Redirect before any page content renders.Resolve targets correctly across hosts
Internal moves: use a root-relative path:
/getting-started. No domain, no.mdxextension.External destinations: use a full URL starting with
https://.Internal paths resolve against the same routing mode as the request (production, branch preview (
~ref), vanity subdomain, or custom domain), so readers stay on the host and ref they started on. You do not need to hard-codehttps://docs.page/owner/repofor in-repo moves.
Do not rely on query strings or hash anchors in redirect values. They are not part of the redirect contract.
Stubs work when you keep a file at the old path. When you delete pages outright — or need to forward many old URLs at once — add a centralized redirects map to docs.json instead of leaving a file behind for each one:
"redirects": {
"/installation": "/getting-started",
"/old-api": "https://api.example.com/reference"
}Keys are the old root-relative paths; values are internal paths or external https:// URLs. docs.page consults this map only when no file exists at the requested path, so it is the tool for URLs whose files were removed. Keep frontmatter stubs for the case where a file still lives at the old path.
See redirects and Redirects → The centralized redirects map.
After you add or change redirect stubs:
See the new page at its updated URL
Open Preview and confirm the moved page renders at the new path. Confirm sidebar links point to the right
href.Confirm the old URL redirects in preview
Open the old URL in the same preview session, for example
/installationafter you moved content to/getting-started. The browser should land on the new page without a 404.Catch broken redirect targets before merge
bashnpx @docs.page/cli checkThe CLI scans frontmatter
redirecttargets the same way it validates internal links in page content. Fix any broken targets before you merge.For severity flags, monorepo paths, and CI setup, see CLI → Check documentation.
| Symptom | Likely cause | Fix |
|---|---|---|
| Old URL returns 404 | No stub file at the old path, or the stub was deleted | Recreate the file at the old path with redirect in frontmatter |
docs check reports a broken redirect | Target path does not match a page or asset in the repo | Use the correct root-relative path (no .mdx). Confirm the destination file exists |
| Redirect sends readers to production from a branch preview | Unlikely with internal paths, they resolve per request context | Use a root-relative path, not a hard-coded production URL. See Redirects |
| External redirect fails validation | Typo in URL or unreachable host | Fix the https:// target. Tune --external-links if CI flakes on third-party sites |
| Old page still appears in the sidebar | docs.json still lists the old href | Update or remove the sidebar entry in Organize |
- Redirects: How per-page redirects work across routing modes, HTTP status, and limits.
- Page frontmatter: Field reference for
redirectand other per-page YAML options. - Organize: Point sidebar entries at the new URL after you move a page.
- Preview: Confirm the new page and redirect locally.
