The documentation system mirrors the shadcn/ui structure, using fumadocs MDX with catch-all dynamic routing. This provides a scalable, maintainable documentation platform with automatic navigation generation.
content/docs/ # Root docs content directory
├── meta.json # Root navigation config
├── getting-started/ # Section folder
│ ├── meta.json # Section config
│ ├── index.mdx # Section landing page
│ └── *.mdx # Doc pages
├── components/ # Component docs
├── operations/ # Operations guides
├── contribute/ # Contributing guides
└── business/ # Business docs
src/app/[lang]/(root)/docs/ # Route handlers
├── [[...slug]]/ # Catch-all dynamic route
│ └── page.tsx # Doc page component
└── layout.tsx # Docs layout with sidebar
src/components/docs/ # Doc components
├── docs-sidebar.tsx # Dynamic sidebar
└── toc.tsx # Table of contents
content/docs/ directorymeta.json files define navigation structure[[...slug]] handles all doc pathspageTreemeta.json controls page orderingDetermine which section your doc belongs to:
getting-started/ - Introduction, setup guidescomponents/ - UI component documentationoperations/ - Feature implementation guidescontribute/ - Contributing guidelinesbusiness/ - Business-related docsCreate your .mdx file in the appropriate section:
---
title: "Your Page Title"
description: "Brief description for SEO and previews"
---
# Your Page Title
Your content here...
## Section 1
Content...
## Section 2
More content...Add your page to the section's meta.json:
{
"title": "Section Name",
"pages": [
"existing-page",
"your-new-page", // Add your page ID (filename without .mdx)
"another-page"
]
}You can import and use React components in MDX:
import { Button } from "@/components/ui/button"
import { CustomChart } from "@/components/charts/custom-chart"
# Using Components
<Button>Click me</Button>
<CustomChart data={[1, 2, 3]} /># Generate MDX files
pnpm fumadocs-mdx
# Build to verify
pnpm build
# Or run dev server
pnpm devRequired fields:
---
title: "Page Title" # Required: Page heading
description: "Description" # Required: SEO description
---Optional fields:
---
links:
doc: "https://docs.example.com"
api: "https://api.example.com"
publishedAt: 2024-01-01
updatedAt: 2024-01-15
author: "John Doe"
tags: ["react", "tutorial"]
---Syntax highlighting with language support:
```typescript
interface User {
name: string
email: string
}
```Markdown tables are supported:
| Feature | Status |
|---------|--------|
| Docs | ✅ |
| Search | 🚧 |
| i18n | ✅ |Use custom callout components:
<Callout type="info">
This is an informational callout.
</Callout>
<Callout type="warning">
This is a warning message.
</Callout>content/docs/meta.json:
{
"title": "Documentation",
"pages": [
"getting-started", // Section folders
"components",
"operations",
"contribute",
"business"
]
}content/docs/getting-started/meta.json:
{
"title": "Getting Started",
"pages": [
"index", // index.mdx (landing page)
"installation", // installation.mdx
"configuration", // configuration.mdx
"first-steps" // first-steps.mdx
]
}Add to mdx-components.tsx:
export const mdxComponents = {
// Override default components
h1: ({ children }) => (
<h1 className="custom-heading">{children}</h1>
),
// Add custom components
Button,
Alert,
CodeBlock,
}Edit src/components/docs/docs-sidebar.tsx:
const TOP_LEVEL_SECTIONS = [
{ name: "Get Started", href: "/docs" },
{ name: "Components", href: "/docs/components" },
// Add new sections here
]container-wrapper classglobals.cssmy-doc-page.mdxauthentication-setup.mdxindex.mdx for section landingpublic/docs/Build Errors
# Regenerate MDX
pnpm fumadocs-mdx
# Clear cache
rm -rf .next
pnpm buildMissing Frontmatter Ensure all MDX files have required frontmatter:
---
title: "Title Here"
description: "Description Here"
---Import Errors
Use absolute imports with @/ alias:
import Component from "@/components/ui/component"Navigation Not Updating
meta.json includes your pagepnpm fumadocs-mdxCreate section-specific layouts:
// src/app/[lang]/(root)/docs/components/layout.tsx
export default function ComponentsLayout({ children }) {
return (
<div className="components-layout">
{children}
</div>
)
}Load dynamic content in MDX:
export const getStaticProps = async () => {
const data = await fetchData()
return { props: { data } }
}
# Dynamic Content
Latest version: {props.data.version}Fumadocs provides built-in search:
import { SearchDialog } from 'fumadocs-ui/components/dialog/search'
<SearchDialog />.mdx files to content/docs/@/ aliasmeta.json filesWe welcome contributions! See /docs/contribute for guidelines.
On This Page
Docs FactoryOverviewArchitectureFile StructureHow It Works1. Content Processing2. Routing3. Navigation4. ComponentsHow to Add DocumentationStep 1: Choose SectionStep 2: Create MDX FileStep 3: Update meta.jsonStep 4: Import Components (Optional)Step 5: Build and TestMDX FeaturesFrontmatterCode BlocksTablesCalloutsNavigation ConfigurationRoot meta.jsonSection meta.jsonCustomizationCustom ComponentsSidebar SectionsStylingBest Practices1. File Naming2. Content Structure3. Frontmatter4. Images5. LinksTroubleshootingCommon IssuesAdvanced FeaturesCustom LayoutsDynamic ContentSearch IntegrationMigration GuideFrom Individual RoutesFrom Other SystemsPerformanceOptimizationMetricsFuture EnhancementsPlanned FeaturesCommunity ContributionsResources