-
Notifications
You must be signed in to change notification settings - Fork 7
Document redirects files in docs.yml #6767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e98791e
Document redirects files in docs.yml
fern-api[bot] 075d318
Merge main into fern/document-redirects-file
devin-ai-integration[bot] 2bc84c1
docs: simplify redirects file guidance
devalog f5490fa
docs: add redirects changelog example
devalog 7f2c88d
docs: clarify redirects setup wording
devalog 05de3ae
docs: tab redirects file examples
devalog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ Redirects map old URLs to new ones so inbound links and search rankings survive | |
|
|
||
| ## Set up redirects | ||
|
|
||
| Configure redirects in `docs.yml`, pointing at either internal paths or external URLs. Use an exact path when a single URL moves, and a [pattern](#pattern-syntax) when a path's descendants move with it: an exact `source` matches that one URL and nothing beneath it, so `/old-folder` leaves `/old-folder/page` alone. | ||
| Configure redirects to internal paths or external URLs in `docs.yml` or in [separate files](#keep-redirects-in-separate-files) that `docs.yml` references. Use an exact path when a single URL moves, and a [pattern](#pattern-syntax) when a path's descendants move with it: an exact `source` matches that one URL and nothing beneath it, so `/old-folder` leaves `/old-folder/page` alone. | ||
|
|
||
| If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include the subpath in both the source and destination paths. | ||
|
|
||
|
|
@@ -55,6 +55,38 @@ Repeat the regular expression in `destination`. A parameter written as `:slug(.* | |
|
|
||
| The optional modifier (`?`) is unsupported. Fern strips each `source` at the first `?` to remove search parameters, so `/old-folder/:slug?` is matched as `/old-folder/:slug`. | ||
|
|
||
| ## Keep redirects in separate files | ||
|
|
||
| Set `redirects` in `docs.yml` to one or multiple YAML file paths: | ||
|
|
||
| <Tabs> | ||
| <Tab title="One file"> | ||
| ```yaml title="docs.yml" | ||
| redirects: ./redirects.yml | ||
| ``` | ||
| </Tab> | ||
|
|
||
| <Tab title="Multiple files"> | ||
| ```yaml title="docs.yml" | ||
| redirects: | ||
| - ./redirects/api.yml | ||
| - ./redirects/guides.yml | ||
| ``` | ||
| </Tab> | ||
| </Tabs> | ||
|
|
||
| Each file must contain a top-level `redirects` list: | ||
|
|
||
| ```yaml title="redirects.yml" | ||
| redirects: | ||
| - source: "/old-path" | ||
| destination: "/new-path" | ||
| - source: "/old-folder/:slug*" | ||
| destination: "/new-folder/:slug*" | ||
| ``` | ||
|
|
||
| File paths are relative to `docs.yml`. Fern evaluates the files in the order listed. Use file paths or inline redirect entries, but not both. | ||
|
|
||
| ## Evaluation order | ||
|
|
||
| Redirects are evaluated top-to-bottom and the first match wins, so list specific paths before broader ones: | ||
|
|
@@ -152,6 +184,20 @@ redirects: | |
| destination: /new-path # must differ from `source` | ||
| ``` | ||
|
|
||
| ### Failed to load redirects: /path/to/redirects.yml does not exist | ||
|
|
||
| `redirects` in `docs.yml` points at a file that isn't on disk. Filepaths resolve relative to `docs.yml`, so `redirects: ./redirects.yml` refers to a file that sits next to it. | ||
|
|
||
| ### Failed to parse /path/to/redirects.yml: the file must nest the list under a top-level `redirects` key | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [vale] <Microsoft.HeadingColons> reported by reviewdog 🐶 |
||
|
|
||
| A redirects file holds a `redirects` key, not a bare list: | ||
|
|
||
| ```yaml title="redirects.yml" | ||
| redirects: | ||
| - source: /old | ||
| destination: /new | ||
| ``` | ||
|
|
||
| ### Circular redirect chain detected: /a → /b → /a | ||
|
|
||
| Two or more [redirects](/learn/docs/configuration/site-level-settings#redirects-configuration) form a cycle: `/a` redirects to `/b`, and `/b` redirects back to `/a` (directly or through more hops). The browser would bounce between them indefinitely. Point every `source` in the chain at the final destination directly, so no `destination` is itself another `source`. | ||
|
|
@@ -164,4 +210,3 @@ redirects: | |
| destination: /c | ||
| ``` | ||
| </llms-only> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [vale] <Microsoft.Contractions> reported by reviewdog 🐶
Use 'doesn't' instead of 'does not'.