Skip to content

Commit bc59051

Browse files
authored
add docu about redirects (#2478)
1 parent 2492c11 commit bc59051

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pages/handbook/product-engineering/playbooks/documentation.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ Good reads:
3131
- [Posthog _How we write docs?_](https://posthog.com/handbook/content/docs)
3232
- [Mintlify Docs Guide](https://www.mintlify.com/guides/introduction)
3333

34+
## Redirects when moving or renaming pages
35+
36+
When you move or rename a documentation page, always add a redirect from the old URL to the new one. This preserves user experience (bookmarks, shared links) and SEO (search engines transfer ranking to the new URL).
37+
38+
**Where:** All redirects live in [lib/redirects.js](https://github.com/langfuse/langfuse-docs/blob/master/lib/redirects.js). Next.js and Cloudflare Pages both use this file.
39+
40+
**How:**
41+
42+
1. For page moves/renames, use **permanent redirects** (they are applied as 301 so search engines update their index).
43+
2. At the bottom of `lib/redirects.js`, add a new dated constant (e.g. `myPageMoveRedirects202601`) with a short comment describing the change.
44+
3. Add one or more `[oldPath, newPath]` tuples. Paths are relative to the site root (e.g. `/docs/evaluation/data-model``/docs/evaluation/experiments/data-model`). You can include hash fragments for specific sections (e.g. `"/docs/foo#section"`).
45+
4. Spread your new constant into the `permanentRedirects` array.
46+
47+
**Important:** Permanent redirects can only be added, not removed (browsers and search engines may cache them). Use a descriptive constant name and comment so future readers understand why the redirect exists.
48+
49+
**Example prompt for Cursor / Claude Code:** You can ask the AI to add redirects for all page changes on your current branch. Copy-paste something like:
50+
51+
> Look at the git diff on my current branch for the `pages/` directory. For every file that was moved or renamed (or whose path changed), add a permanent redirect in `lib/redirects.js`: old URL → new URL. Use the same pattern as existing redirects: create a new dated constant (e.g. `myChangeRedirects202601`) with a short comment, add `[oldPath, newPath]` tuples (paths relative to site root, e.g. `/docs/foo` not `pages/docs/foo.mdx`), and spread it into the `permanentRedirects` array. Only add redirects for pages that actually changed path; do not add redirects for edits to existing files.
52+
3453
## Changelog
3554

3655
For new capabilities and updates, we write [changelog](/changelog) posts.

0 commit comments

Comments
 (0)