Skip to content

Commit 6127e9c

Browse files
authored
(docs) Move redirects info into a snippet, make clarifying updates (#804)
1 parent 87ca92c commit 6127e9c

File tree

3 files changed

+40
-59
lines changed

3 files changed

+40
-59
lines changed

fern/products/docs/pages/customization/what-is-docs-yml.mdx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -211,25 +211,7 @@ logo:
211211

212212
## Redirects configuration
213213

214-
```yaml docs.yml
215-
redirects:
216-
- source: "/old-path"
217-
destination: "/new-path"
218-
- source: "/old-folder/*"
219-
destination: "/new-folder/*"
220-
```
221-
222-
<ParamField path="source" type="string" required={true}>
223-
The path that you want to redirect from.
224-
</ParamField>
225-
226-
<ParamField path="destination" type="string" required={true}>
227-
The path that you want to redirect to.
228-
</ParamField>
229-
230-
<ParamField path="permanent" type="boolean" required={false}>
231-
Toggle between **permanent** and **temporary** redirect (default `false`). When true, the status code is 308. When false the status code is 307.
232-
</ParamField>
214+
<Markdown src="/snippets/redirects.mdx" />
233215

234216
## NavBar links configuration
235217

fern/products/docs/pages/seo/redirects.mdx

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,7 @@ subtitle: Set up the navigation for your documentation site built with Fern Docs
55

66
## Redirects
77

8-
The `redirects` object allows you to redirect traffic from one path to another. You can redirect exact paths or use dynamic patterns with [`regex`](https://www.npmjs.com/package/path-to-regexp) parameters like `:slug`.
9-
10-
11-
<CodeBlock title="docs.yml">
12-
```yml
13-
redirects:
14-
# Exact path redirects
15-
- source: "/old-path"
16-
destination: "/new-path"
17-
- source: "/old-folder/path"
18-
destination: "/new-folder/path"
19-
20-
# Regex-based redirects
21-
- source: "/old-folder/:slug" # <- /old-folder/foo, /old-folder/bar, etc.
22-
destination: "/new-folder/:slug"
23-
- source: "/old-folder/:slug*" # <- /incorrect, /incorrect/foo/bar/baz, etc.
24-
destination: "/new-folder/:slug*"
25-
```
26-
</CodeBlock>
27-
28-
<Info>
29-
Parameters suffixed with an asterisk (`*`) denote a match with zero or more.
30-
</Info>
31-
32-
### Setting permanent redirects
33-
34-
By default, the redirects implement temporary (302) redirects. If you would like to implement permanent (301) redirects, you can set `permanent: true`.
35-
36-
<CodeBlock title="docs.yml">
37-
```yml
38-
redirects:
39-
- source: "/old-subdomain"
40-
destination: "/new-subdomain"
41-
permanent: true
42-
```
43-
</CodeBlock>
44-
45-
<Note title="Subpaths">
46-
If your docs are hosted on a subpath (like `buildwithfern.com/learn`), be sure to include the subpath in the redirect.
47-
</Note>
8+
<Markdown src="/snippets/redirects.mdx" />
489

4910
## Links
5011

fern/snippets/redirects.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
The `redirects` object allows you to redirect traffic from one path to another. You can redirect exact paths or use dynamic patterns with [`regex`](https://www.npmjs.com/package/path-to-regexp) parameters like `:slug`.
2+
3+
If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include the subpath in both the source and destination paths.
4+
5+
6+
<CodeBlock title="docs.yml">
7+
```yml
8+
redirects:
9+
# Exact path redirects
10+
- source: "/old-path"
11+
destination: "/new-path"
12+
- source: "/old-folder/path"
13+
destination: "/new-folder/path"
14+
permanent: true
15+
16+
# Regex-based redirects
17+
- source: "/old-folder/:slug" # <- /old-folder/foo, /old-folder/bar, etc.
18+
destination: "/new-folder/:slug"
19+
- source: "/old-folder/:slug*" # <- /incorrect, /incorrect/foo/bar/baz, etc.
20+
destination: "/new-folder/:slug*"
21+
```
22+
</CodeBlock>
23+
24+
<Info>
25+
Parameters suffixed with an asterisk (`*`) match zero or more path segments, capturing everything that follows in the URL. Use this when redirecting entire folder structures while preserving nested paths.
26+
</Info>
27+
28+
<ParamField path="source" type="string" required={true}>
29+
The path that you want to redirect from.
30+
</ParamField>
31+
32+
<ParamField path="destination" type="string" required={true}>
33+
The path that you want to redirect to.
34+
</ParamField>
35+
36+
<ParamField path="permanent" type="boolean" required={false}>
37+
Toggle between **permanent** and **temporary** redirect (default `false`). When true, the status code is 308. When false, the status code is 307.
38+
</ParamField>

0 commit comments

Comments
 (0)