Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions fern/products/docs/pages/customization/what-is-docs-yml.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,25 +211,7 @@ logo:

## Redirects configuration

```yaml docs.yml
redirects:
- source: "/old-path"
destination: "/new-path"
- source: "/old-folder/*"
destination: "/new-folder/*"
```

<ParamField path="source" type="string" required={true}>
The path that you want to redirect from.
</ParamField>

<ParamField path="destination" type="string" required={true}>
The path that you want to redirect to.
</ParamField>

<ParamField path="permanent" type="boolean" required={false}>
Toggle between **permanent** and **temporary** redirect (default `false`). When true, the status code is 308. When false the status code is 307.
</ParamField>
<Markdown src="/snippets/redirects.mdx" />

## NavBar links configuration

Expand Down
41 changes: 1 addition & 40 deletions fern/products/docs/pages/seo/redirects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,7 @@ subtitle: Set up the navigation for your documentation site built with Fern Docs

## Redirects

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`.


<CodeBlock title="docs.yml">
```yml
redirects:
# Exact path redirects
- source: "/old-path"
destination: "/new-path"
- source: "/old-folder/path"
destination: "/new-folder/path"

# Regex-based redirects
- source: "/old-folder/:slug" # <- /old-folder/foo, /old-folder/bar, etc.
destination: "/new-folder/:slug"
- source: "/old-folder/:slug*" # <- /incorrect, /incorrect/foo/bar/baz, etc.
destination: "/new-folder/:slug*"
```
</CodeBlock>

<Info>
Parameters suffixed with an asterisk (`*`) denote a match with zero or more.
</Info>

### Setting permanent redirects

By default, the redirects implement temporary (302) redirects. If you would like to implement permanent (301) redirects, you can set `permanent: true`.

<CodeBlock title="docs.yml">
```yml
redirects:
- source: "/old-subdomain"
destination: "/new-subdomain"
permanent: true
```
</CodeBlock>

<Note title="Subpaths">
If your docs are hosted on a subpath (like `buildwithfern.com/learn`), be sure to include the subpath in the redirect.
</Note>
<Markdown src="/snippets/redirects.mdx" />

## Links

Expand Down
38 changes: 38 additions & 0 deletions fern/snippets/redirects.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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`.

If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include the subpath in both the source and destination paths.


<CodeBlock title="docs.yml">
```yml
redirects:
# Exact path redirects
- source: "/old-path"
destination: "/new-path"
- source: "/old-folder/path"
destination: "/new-folder/path"
permanent: true

# Regex-based redirects
- source: "/old-folder/:slug" # <- /old-folder/foo, /old-folder/bar, etc.
destination: "/new-folder/:slug"
- source: "/old-folder/:slug*" # <- /incorrect, /incorrect/foo/bar/baz, etc.
destination: "/new-folder/:slug*"
```
</CodeBlock>

<Info>
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.
</Info>

<ParamField path="source" type="string" required={true}>
The path that you want to redirect from.
</ParamField>

<ParamField path="destination" type="string" required={true}>
The path that you want to redirect to.
</ParamField>

<ParamField path="permanent" type="boolean" required={false}>
Toggle between **permanent** and **temporary** redirect (default `false`). When true, the status code is 308. When false, the status code is 307.
</ParamField>