Configure links and redirects for your site

Set up the navigation for your documentation site built with Fern Docs using the docs.yml file

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 parameters like :slug.

docs.yml
1redirects:
2 # Exact path redirects
3 - source: "/old-path"
4 destination: "/new-path"
5 - source: "/old-folder/path"
6 destination: "/new-folder/path"
7
8 # Regex-based redirects
9 - source: "/old-folder/:slug" # <- /old-folder/foo, /old-folder/bar, etc.
10 destination: "/new-folder/:slug"
11 - source: "/old-folder/:slug*" # <- /incorrect, /incorrect/foo/bar/baz, etc.
12 destination: "/new-folder/:slug*"

Parameters suffixed with an asterisk (*) denote a match with zero or more.

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.

docs.yml
1redirects:
2 - source: "/old-subdomain"
3 destination: "/new-subdomain"
4 permanent: true
Subpaths

If your docs are hosted on a subpath (like buildwithfern.com/learn), be sure to include the subpath in the redirect.

You can add a link to an external page within your sidebar navigation with the following configuration:

docs.yml
1navigation:
2 - section: Home
3 contents:
4 - page: Introduction
5 path: ./intro.mdx
6 - link: Our YouTube Channel
7 href: https://www.youtube.com/
An external link within navigation