Features
Routing and Collections
Learn how file paths become URLs and how collection roots and redirects work.
Overview
One optional catch-all App Router route serves the entire documentation site. A page's path under content/docs becomes its URL.
content/docs/api-reference/utilities.mdx
→ /api-reference/utilitiesFile locations
app/[[...slug]]/page.tsxresolves, renders, and generates metadata.lib/source.tsprovides pages and static parameters.lib/docs-collections.tsdefines roots and redirects.
Architecture
const { slug } = await params;
const redirectPath = getDocsRedirect(slug);
if (redirectPath) redirect(redirectPath);
const page = source.getPage(slug);
if (!page) notFound();generateStaticParams() enumerates known pages for production. generateMetadata() reads each page title and description. Unknown paths render app/not-found.tsx.
Add a collection
- Create
content/docs/tutorials/meta.jsonwith"root": true. - Add an introduction page.
- Add a record to
docsCollections. - Add
"tutorials"tocontent/docs/meta.json.
{
"title": "Tutorials",
"root": true,
"pages": ["introduction"]
}Customize a base URL
docsRoute in lib/shared.ts is passed to the source loader. Changing it affects generated page URLs and requires matching route/layout changes; treat this as an architectural change and verify every internal link.
Warning: Moving an MDX file changes its URL. Add a redirect in
getDocsRedirect()to preserve external links and search ranking.