Configure your site navigation

Every Fern Docs website has a special configuration file called docs.yml. Use this file to configure the navigation for your documentation site.

Here’s a complete example of a docs.yml file:

An example docs.yml
1# yaml-language-server: $schema=https://schema.buildwithfern.dev/docs-yml.json
2navigation:
3 - section: Home
4 contents:
5 - page: Introduction
6 path: ./intro.mdx
7 - folder: ./auth # directory
8 title: Authentication
9 - api: API Reference
10navbar-links:
11 - type: secondary
12 text: Contact support
13 url: https://example.com/support
14 - type: primary
15 text: Login
16 url: https://example.com/login

Sections, contents, pages, and folders

Sections organize your documentation in the left-side nav bar. Each section has a name and a list of contents. Sections appear in the order listed in docs.yml.

In contents, you can add individual pages, folders, or both:

  • page Manually list your pages with names and corresponding file paths.
  • folder Auto-discover pages from a directory and add them to your navigation.

You can combine folder-based navigation with manually defined pages.

API Reference section

Use the special api key to create an automatically generated API Reference section. You don’t need to add any pages to it manually. For more information, see the Generate API Reference page.

docs.yml
1navigation:
2 - section: Introduction
3 contents:
4 - page: My page
5 path: ./pages/my-page.mdx
6 - api: API Reference

Create an .md or .mdx file. Then in docs.yml, add a new page to the contents list, providing the path to the file you created.

docs.yml
1navigation:
2 - section: Introduction
3 contents:
4 - page: My page
5 path: ./pages/my-page.mdx
6 - page: Another page
7 path: ./pages/another-page.mdx

Create a directory with one or more .md or .mdx files. Add a folder key to your navigation configuration with the relative path to the directory you just created. Fern discovers all files in the directory and adds them to the navigation.

docs.yml
1navigation:
2 - section: Introduction
3 contents:
4 - folder: ./pages/getting-started
5 title: Getting started # Optional, defaults to folder name

For the pages in a folder, Fern automatically converts filenames to titles and URL slugs, creates nested sections from subdirectories, and sorts pages alphabetically.

Control page order

Use frontmatter position to control page order. Pages with a position field are sorted numerically before alphabetically sorted pages.

/pages/getting-started/quickstart.mdx
1 ---
2 title: Quickstart
3 position: 1
4 ---

Hiding content

To hide a page, folder, or section, add hidden: true. Hidden content (including all pages within a folder) is still accessible via direct URL but is excluded from search and won’t be indexed.

docs.yml
1navigation:
2 - section: Introduction
3 contents:
4 - page: My page
5 path: ./pages/my-page.mdx
6 - page: Hidden page
7 hidden: true
8 path: ./pages/my-hidden-page.mdx
9 - folder: .pages/features
10 title: Hidden folder
11 hidden: true
12 - section: Hidden sections
13 hidden: true
14 contents:
15 - page: Another hidden page
16 path: ./pages/also-hidden.mdx

Availability

Set availability for individual pages, sections, or folders. Pages inherit availability from their parent section or folder unless explicitly overridden.

Options are: stable, generally-available, in-development, pre-release, deprecated, or beta.

Availability
1navigation:
2 - section: Developer resources
3 availability: generally-available
4 contents:
5 - page: Code examples # Inherits generally-available
6 path: ./pages/code-examples.mdx
7 - folder: ./pages/cli-tools # Inherits generally-available
8 title: CLI tools
9 - page: Testing framework
10 path: ./pages/testing-framework.mdx
11 availability: beta # Overrides section-level availability
12 - folder: ./pages/performance-monitoring
13 title: Performance monitoring
14 availability: in-development # Overrides section-level availability

If you have different versions of your docs, section, folder, and page availability should be set in the .yml files that define the navigational structure for each version.

Folder slugs

Specify a custom URL slug for the folder section. If not provided, a slug will be generated from the folder name.

docs.yml (4)
1navigation:
2 - folder: ./pages/guides
3 title: Guides
4 slug: user-guides

Skip adding the folder’s slug to the URL path. This is useful when you want the pages to appear at the parent level in the URL structure.

docs.yml
1navigation:
2 - folder: ./pages/guides
3 title: Guides
4 skip-slug: true

Section overviews

To add an overview page to a section, add a path property to the section.

Example section with an overview
1navigation:
2 - section: Introduction
3 contents:
4 - page: My page
5 path: ./pages/my-page.mdx
6 - section: Guides
7 path: ./pages/guide-overview.mdx
8 contents:
9 - page: Simple guide
10 path: ./pages/guides/simple.mdx
11 - page: Complex guide
12 path: ./pages/guides/complex.mdx

Nested sections

If you’d like a section to toggle into more sections and pages, you can nest sections within sections. Here’s an example:

Example navigation config with nested sections
1navigation:
2 - tab: guides
3 layout:
4 - section: Learn
5 contents:
6 - section: Key concepts
7 contents:
8 - page: Embeddings
9 path: ./docs/pages/embeddings.mdx
10 - page: Prompt engineering
11 path: ./docs/pages/prompts.mdx
12 - section: Generation
13 contents:
14 - page: Command nightly
15 path: ./docs/pages/command.mdx
16 - page: Likelihood
17 path: ./docs/pages/likelihood.mdx

Result of above docs.yml example

Collapsed sections or folders

You can set sections or folders to be collapsed by default when the page loads by adding collapsed: true. This helps keep the navigation tidy when you have many sections or want to highlight the most important sections by keeping others collapsed.

Example config with collapsed section
1navigation:
2 - section: Getting started
3 contents:
4 - page: Introduction
5 path: ./pages/intro.mdx
6 - folder: ./pages/features
7 title: Features
8 collapsed: true
9 - section: Advanced topics
10 collapsed: true
11 contents:
12 - page: Custom CSS
13 path: ./pages/advanced/css.mdx
14 - page: Analytics
15 path: ./pages/advanced/analytics.mdx

Add icons next to sections, pages, and folders using the icon key.

Icons can be in three formats:

  • Font Awesome icons: Use icon names like fa-solid fa-rocket. Pro and Brand Icons from Font Awesome are supported.
  • Custom image files: Use relative paths to image files (e.g., ./assets/icons/my-icon.svg or ../assets/icons/my-icon.png). Paths are relative to the docs.yml file.
  • Inline SVG: Provide an SVG string wrapped in quotes (e.g., "<svg>...</svg>").
Example config with different icon files
1navigation:
2 - section: Home
3 icon: fa-regular fa-home # Font Awesome icon
4 contents:
5 - page: Introduction
6 icon: ./assets/icons/intro-icon.svg # Custom image file
7 path: ./pages/intro.mdx
8 - folder: .pages/features
9 title: Custom features
10 icon: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'><path d='M12 2L2 7v10c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-10-5z'/></svg>" # Inline SVG
11 path: ./pages/custom.mdx
12 - api: API Reference
13 icon: fa-regular fa-puzzle

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

Tabs

You can add tabs to group sections of content together. Tabs can contain different layouts and navigation structures, and you can use tab variants to show different content variations within a single tab. For more information, see Tabs and tab variants.

Versions

If you have multiple versions of your documentation, you can introduce a dropdown version selector by specifying the versions. For more information, check out the documentation on versioning.

Product switching

If you have multiple products in your documentation, you can introduce a dropdown product selector by creating separate product configuration files. Each product can contain its own distinct versions, tabs, sections, pages, and API References, though products can also share content.

docs.yml
1products:
2 - display-name: Product A
3 path: ./products/product-a.yml
4 icon: fa-solid fa-leaf # optional
5 slug: product-a # optional
6 subtitle: Product A subtitle # optional
7 - display-name: Product B
8 path: ./products/product-b/latest.yml # <-- default showing latest
9 image: ./images/product-b.png # optional
10 slug: product-b # optional
11 subtitle: Product B subtitle # optional