Customizing slugs within your site

View as Markdown

By default, Fern generates the slug of a page based on the navigation structure in the docs.yml file.

Example without tabs
docs.yml
1instances:
2 - url: plantstore.docs.buildwithfern.com
3
4navigation:
5 - section: Get Started
6 contents:
7 - page: Welcome
8 path: ./docs/pages/welcome.mdx

In the example above, the Welcome page would be hosted at plantstore.docs.buildwithfern.com/get-started/welcome.

docs.yml
1instances:
2 - url: plantstore.docs.buildwithfern.com
3
4tabs:
5 docs:
6 display-name: Docs
7 reference:
8 display-name: API Reference
9
10navigation:
11 - tab: docs
12 layout:
13 - section: Get Started
14 contents:
15 - page: Welcome
16 path: ./docs/pages/welcome.mdx

In the example above, the Welcome page would be hosted at plantstore.docs.buildwithfern.com/docs/get-started/welcome.

You can customize these default slugs by renaming them or skipping them entirely.

Renaming slugs

Set the slug property in docs.yml or in a page’s frontmatter to customize the URL path.

Modify a page or section slug

To modify the slug used for a page or section, you can set the slug within the navigation object.

docs.yml
1navigation:
2 - section: Get Started
3 slug: start
4 contents:
5 - page: Welcome
6 slug: intro
7 path: ./docs/pages/welcome.mdx

In the example above, the Welcome page would be hosted at plantstore.docs.buildwithfern.com/start/intro.

Modify a tab slug

To modify the slug used for a tab, you can set the slug within the tabs object.

docs.yml
1tabs:
2 docs:
3 display-name: Docs
4 slug: guides
5 reference:
6 display-name: API Reference
7
8navigation:
9 - tab: docs
10 layout:
11 - section: Get Started
12 contents:
13 - page: Welcome
14 path: ./docs/pages/welcome.mdx

In the example above, the Welcome page would be hosted at plantstore.docs.buildwithfern.com/guides/get-started/welcome.

Modify a landing page’s slug

To modify the slug used for a landing page, you can set the slug within the landing-page object.

docs.yml
1landing-page:
2 page: Page Title
3 path: path/to/landing-page.mdx
4 slug: /welcome

Override a page’s slug with frontmatter

Frontmatter slugs take precedence over slugs generated or set in docs.yml, giving you full control over a page’s URL.

docs.yml
1navigation:
2 - section: Get Started
3 slug: start
4 contents:
5 - page: Quickstart
6 path: ./docs/pages/quickstart.mdx

With this configuration, the page would normally be at plantstore.docs.buildwithfern.com/start/quickstart. To override this, set slug in the page’s frontmatter:

quickstart.mdx
1---
2title: Quickstart
3slug: start-up
4---

The page is now available at plantstore.docs.buildwithfern.com/start/start-up instead. See frontmatter configuration for more details.

Renaming slugs for subheadings

By default, deep links to subheadings are generated by appending a # and the subheading title (converted to kebab-casing-convention) onto the page URL.

docs.yml
1navigation:
2 - section: Get Started
3 contents:
4 - page: Welcome
5 path: ./docs/pages/welcome.mdx
welcome.mdx
1...
2
3## Frequently Asked Questions
4...

The link to this section will be available at plantstore.docs.buildwithfern.com/get-started/welcome#frequently-asked-questions.

To rename the slug of the subheading, add the desired slug:

welcome.mdx
1## Frequently Asked Questions [#faqs]

The link to this section will now be available at plantstore.docs.buildwithfern.com/get-started/welcome#faqs.

Skipping slugs

To ignore a tab or section when generating the slug, simply indicate skip-slug: true.

docs.yml
1instances:
2 - url: plantstore.docs.buildwithfern.com
3
4navigation:
5 - section: Get Started
6 skip-slug: true
7 contents:
8 - page: Welcome
9 path: ./docs/pages/welcome.mdx

In the example above, the Welcome page would be hosted at plantstore.docs.buildwithfern.com/welcome.

docs.yml
1instances:
2 - url: plantstore.docs.buildwithfern.com
3
4tabs:
5 docs:
6 display-name: Docs
7 skip-slug: true
8 reference:
9 display-name: API Reference
10
11navigation:
12 - tab: docs
13 layout:
14 - section: Get Started
15 skip-slug: true
16 contents:
17 - page: Welcome
18 path: ./docs/pages/welcome.mdx

In the example above, the Welcome page would be hosted at plantstore.docs.buildwithfern.com/welcome.