TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/shuding/nextra/llms.txt
Use this file to discover all available pages before exploring further.
content/ directory is Nextra’s dedicated folder for Markdown and MDX content files. It lets you organize pages without following the page filename convention required by the Next.js App Router, making it an ideal home for documentation, blog posts, and other content-heavy sites.
Why Use the content/ Directory?
The content/ directory solves two common problems:
- Migration from the Next.js
pagesrouter — Rename your existingpages/directory tocontent/and get up and running with minimal changes. - Cleaner file paths — Instead of
app/configuration/page.mdx, you writecontent/configuration.mdx. The route stays the same; the file tree is much easier to navigate.
How Nextra Discovers Content Files
At build time, Nextra uses the fast-glob pattern{src/,}content to locate your content directory. It checks for content/ at the project root first, then falls back to src/content/. No manual configuration is needed — the directory is auto-detected.
.md or .mdx extension, along with any _meta.js configuration files.
Supported File Extensions
| Extension | Description |
|---|---|
.mdx | MDX files — Markdown with embedded JSX components |
.md | Plain Markdown files — processed the same way as MDX |
URL Route Mapping
Files insidecontent/ map directly to URL routes. The content/ directory itself is stripped from the path, and the file extension is removed:
| File path | URL route |
|---|---|
content/index.mdx | / |
content/about.mdx | /about |
content/docs/intro.mdx | /docs/intro |
content/docs/advanced/config.md | /docs/advanced/config |
content/docs/index.mdx | /docs |
An
index.mdx file inside a subdirectory maps to the directory root. For example, content/docs/index.mdx is served at /docs.Setting Up the content/ Directory
You can keep the
content/ directory at the root of your project or inside a src/ directory. Nextra detects both automatically.If you want your content served from a sub-path instead of
/, set the contentDirBasePath option in next.config.mjs:import nextra from 'nextra'
const withNextra = nextra({
contentDirBasePath: '/docs' // Or even nested, e.g. `/docs/advanced`
})
export default withNextra({})
Place a
[[...mdxPath]]/page.jsx file inside your app/ directory. This single catch-all route acts as the gateway to your content/ directory and delegates rendering to Nextra:your-project/
├── app/
│ ├── layout.jsx
│ └── [[...mdxPath]]/
│ └── page.jsx ← catch-all route
├── content/
│ └── index.mdx ← your first page
├── next.config.mjs
└── package.json
If you set
contentDirBasePath in next.config.mjs, place [[...mdxPath]]/page.jsx inside the matching subdirectory. For example, contentDirBasePath: '/docs' → app/docs/[[...mdxPath]]/page.jsx.Start your development server. Nextra’s
content/ directory has several advantages over third-party content-watching solutions:Using src/content/
If you prefer to keep application code under a src/ folder, move the content/ directory there:
src/content/ using the same glob pattern and applies identical route mapping rules. No configuration change is needed.
Example Directory Tree
A typical docs site using thecontent/ directory might look like this:
_meta.js file to control the order and titles of items in the sidebar.