Fumadocs

Routing

A shared convention for organizing your documents

Before reading

This guide only applies for content sources that uses loader() API, such as Fumadocs MDX.

Overview

While Next.js handles routing, Fumadocs generates page slugs and sidebar items (page tree) from your content directory using loader().

You can define folders and pages similar to the file-system based routing of Next.js.

index.mdx
getting-started.mdx

File

A MDX or Markdown file, you can customise its frontmatter.

---
title: My Page
description: Best document ever
icon: HomeIcon
full: true
---
 
## Learn More
namedescription
titleThe title of page
descriptionThe description of page
iconThe name of icon, see Icons
fullFill all available space on the page (Fumadocs UI)

Fumadocs MDX

You can use the schema option to add frontmatter properties.

Slugs

The slugs of a page are generated from its file path.

path (relative to content folder)slugs
./dir/page.mdx['dir', 'page']
./dir/index.mdx['dir']

Folder

Organize multiple pages, you can create a Meta file to customise folders.

Folder Group

By default, putting a file into folder will change its slugs. You can wrap the folder name in parentheses to avoid impacting the slugs of child files.

path (relative to content folder)slugs
./(group-name)/page.mdx['page']

Meta

Customise folders by creating a meta.json file in the folder.

meta.json
{
  "title": "Display Name",
  "icon": "MyIcon",
  "pages": ["index", "getting-started"],
  "defaultOpen": true
}
namedescription
titleDisplay name
iconThe name of icon, see Icons
pagesFolder items (see below)
defaultOpenOpen the folder by default

Pages

By default, folder items are sorted alphabetically.

You can control the order of items using pages, items are not included unless they are listed inside.

meta.json
{
  "title": "Name of Folder",
  "pages": ["guide", "components", "./nested/page"]
}
meta.json
guide.mdx
components.mdx
nested/page.mdx

Separator

meta.json
{
  "pages": ["guide", "---My Separator---", "components"]
}

Rest

Add a ... item to include remaining pages (sorted alphabetically), or z...a for descending order.

meta.json
{
  "pages": ["guide", "..."]
}

You can add !name to prevent an item from being included.

meta.json
{
  "pages": ["guide", "...", "!components"]
}

Extract

You can extract the items from a folder with ...folder_name.

meta.json
{
  "pages": ["guide", "...nested"]
}

Use the syntax [Text](url) to insert links, or [Icon][Text](url) to add icon.

meta.json
{
  "pages": [
    "[Vercel](https://vercel.com)",
    "[Triangle][Vercel](https://vercel.com)"
  ]
}

Icons

Since Fumadocs doesn't include an icon library, you have to convert the icon names to JSX elements in runtime, and render it as a component.

You can add an icon handler to loader().

Root Folder

Marks the folder as a root folder, only items in the opened root folder will be considered.

meta.json
{
  "title": "Name of Folder",
  "description": "The description of root folder (optional)",
  "root": true
}

For example, when you are in a root folder called framework, the other folders (e.g. headless) are not shown on the sidebar and other navigation elements.

Index pages will also be hidden unless it is listed in the pages property.

index.mdx (hidden)
current-page.mdx
other-pages.mdx
my-page.mdx

Fumadocs UI

Fumadocs UI renders root folders as Sidebar Tabs, which allows user to switch between them.

Internationalization

You can add Markdown/meta files for different languages by attending .{locale} to your file name, like page.cn.md and meta.cn.json.

Make sure to create a file for the default locale first, the locale code is optional (e.g. both get-started.mdx and get-started.en.mdx are accepted).

meta.json
meta.cn.json
get-started.mdx
get-started.cn.mdx

How is this guide?

On this page