|
24 | 24 | - [Placeholders and dummy data](#placeholders-and-dummy-data) |
25 | 25 | - [UI references](#ui-references) |
26 | 26 | - [Diagrams](#diagrams) |
27 | | - - [Import \& reference content](#import--reference-content) |
| 27 | + - [Import & reference content](#import--reference-content) |
28 | 28 | - [Markdown partials](#markdown-partials) |
29 | 29 | - [Code snippets](#code-snippets) |
30 | 30 | - [From GitHub](#from-github) |
|
35 | 35 | - [Ory Console](#ory-console) |
36 | 36 | - [Navigate to Ory Console Pages](#navigate-to-ory-console-pages) |
37 | 37 | - [Testing](#testing) |
| 38 | + - [Redirects](#redirects) |
| 39 | + - [How to add a redirect](#how-to-add-a-redirect) |
38 | 40 | - [Formatting documentation](#formatting-documentation) |
39 | 41 | - [Adding content to "Examples" page](#adding-content-to-examples-page) |
40 | 42 | - [CLI and API reference - auto-generated content](#cli-and-api-reference---auto-generated-content) |
@@ -476,6 +478,48 @@ To test the documentation locally: |
476 | 478 | 4. Create a production build to check for any technical issues, such as invalid |
477 | 479 | internal links. Run `npm run build`. |
478 | 480 |
|
| 481 | +### Redirects |
| 482 | + |
| 483 | +When the URL of a document changes, you must set up a redirect to preserve SEO |
| 484 | +and prevent broken links. Without redirects, the original URL returns a 404 |
| 485 | +error, breaking existing links from external sites and causing search engines to |
| 486 | +lose page authority. |
| 487 | + |
| 488 | +The rule is: if the URL in the browser changes, add a redirect. If it doesn't, |
| 489 | +no redirect is required. |
| 490 | + |
| 491 | +Filenames don't always determine URLs. Ory documentation uses numbered prefixes |
| 492 | +in filenames and sets URLs explicitly in the front matter. Renaming with no |
| 493 | +other changes doesn't require a redirect because the final URL stays the same. |
| 494 | + |
| 495 | +You must add a redirect when you |
| 496 | + |
| 497 | +- change the `slug` or `id` property in the document front matter |
| 498 | +- delete a document |
| 499 | +- move a document to a different directory (if it changes the URL path) |
| 500 | + |
| 501 | +#### How to add a redirect |
| 502 | + |
| 503 | +Add redirects to the vercel.json file in the repository root. Use this format: |
| 504 | + |
| 505 | +```json |
| 506 | +{ |
| 507 | + "redirects": [ |
| 508 | + { |
| 509 | + "source": "/docs/old-path", |
| 510 | + "destination": "/docs/new-path", |
| 511 | + "permanent": false |
| 512 | + } |
| 513 | + ] |
| 514 | +} |
| 515 | +``` |
| 516 | + |
| 517 | +- Start with permanent: false (302 redirect) until you confirm the redirect |
| 518 | + works in the preview or production environment. |
| 519 | +- Change to permanent: true (301 redirect) after you verify the redirect |
| 520 | + functions correctly. |
| 521 | +- Test the redirect in the Vercel preview deployment before merging. |
| 522 | + |
479 | 523 | ## Formatting documentation |
480 | 524 |
|
481 | 525 | All documents and other files in this repository must be formatted with Prettier |
|
0 commit comments