Markdown
How to write documents
Introduction
Fumadocs provides many useful extensions to MDX, a markup language. Here is a brief introduction to the default MDX syntax of Fumadocs.
MDX is not the only supported format of Fumadocs. In fact, you can use any renderers such as next-mdx-remote
or CMS.
MDX
We recommend MDX, a superset of Markdown with JSX syntax. It allows you to import components, and use them right in the document, or even export values.
See:
- MDX Syntax.
- GFM (GitHub Flavored Markdown) is also supported, see GFM Specification.
Images
Images are automatically optimized for next/image
.
Auto Links
Internal links use the next/link
component to allow prefetching and avoid hard-reload.
External links will get the default rel="noreferrer noopener" target="_blank"
attributes for security.
Cards
Useful for adding links.
Fetching, Caching, and Revalidating
Learn more about caching in Next.js
href is optional
fetch
in Next.js.Home
You can include icons too.
"Further Reading" Section
You can do something like:
This will show the other pages in the same folder as cards.
Layout Links
Sidebar Links
Callouts
Useful for adding tips/warnings, it is included by default. You can specify the type of callout:
info
(default)warn
error
Title
Title
Hello World
Headings
An anchor is automatically applied to each heading, it sanitizes invalid characters like spaces. (e.g. Hello World
to hello-world
)
TOC Settings
The table of contents (TOC) will be generated based on headings, you can also customise the effects of headings:
Custom Anchor
You can add [#slug]
to customise heading anchors.
You can also chain it with TOC settings like:
To link people to a specific heading, add the heading id to hash fragment: /page#my-heading-id
.
Codeblock
Syntax Highlighting is supported by default using Rehype Code.
You can add a title to the codeblock.
Shiki Transformers
We support some of the Shiki Transformers, allowing you to highlight/style specific lines.
Tab Groups
You can use code blocks with the <Tab />
component.
Note that you can add MDX components instead of importing them in MDX files.
Include
This is only available on Fumadocs MDX.
Reference another file (can also be a Markdown/MDX document).
Specify the target file path in <include>
tag (relative to the MDX file itself).
See other usages.
Additional Features
You may be interested:
Math
Mermaid
Twoslash
Package Install
Generate commands for installing packages via package managers.
To enable, see Remark Install.
How is this guide?