Sections let you divide your documentation into separate top-level areas - for example "Guides", "API Reference", and "SDKs". Each section gets its own sidebar and appears as a horizontal tab bar below the site header.
Sections are entirely opt-in. If you don't configure them, nothing changes - your site works exactly as before with a single flat navigation.
The simplest way to add sections is through page frontmatter. Add a section field to group pages, and an optional sectionOrder to control the order of sections in the bar.
The section slug is derived automatically from the label - lowercased with spaces replaced by hyphens. So "API Reference" becomes api-reference.
Pages without a section field stay at the root URL and appear under a default tab labeled "Docs". You can rename this tab with the sectionLabel field on your index.mdx:
---
title: "Welcome"
sectionLabel: "Guides"
---You can organize each section's files in a subdirectory that matches the section slug. When the directory name matches, Doccupine automatically assigns the files to that section and strips the directory from the URL.
docs/
index.mdx
getting-started.mdx
platform/
index.mdx -> /platform
auth.mdx -> /platform/authWhere platform/index.mdx has:
---
title: "Platform Overview"
section: "Platform"
sectionOrder: 1
category: "Getting Started"
---The directory platform/ matches the section slug platform, so it is stripped. platform/index.mdx serves at /platform/ and platform/auth.mdx serves at /platform/auth.
Once a section exists, any file placed in a matching directory is automatically assigned to it - even without a section field in its own frontmatter. Only the first file needs section and sectionOrder to create the section. After that, the directory does the work.
Files at the root level with a section field work too - they keep their full slug under the section prefix.
If a section has no index page (no file at its root URL), Doccupine generates a redirect to the first page in that section, sorted by categoryOrder then order.
You can override the auto-redirect by creating an index.mdx in the section's directory.
You can also keep all files at the root and rely purely on frontmatter:
---
title: "Authentication"
section: "API Reference"
sectionOrder: 2
category: "Auth"
categoryOrder: 1
order: 1
---This page would be served at /api-reference/authentication.
For full control over slugs, create a sections.json file at your project root (the same folder where you run npx doccupine).
[
{ "label": "Docs", "slug": "" },
{ "label": "Platform", "slug": "platform" }
]This defines two sections. Pages are assigned automatically:
platform/ directory belong to the "Platform" section (directory name matches slug).section: "Platform" in their frontmatter also belong to it.No directory field is needed when the directory name already matches the section slug.
When the directory name differs from the slug, use the directory field to map them:
[
{ "label": "Guides", "slug": "", "directory": "guides" },
{ "label": "API Reference", "slug": "api", "directory": "api-reference" },
{ "label": "SDKs", "slug": "sdks", "directory": "sdks" }
]"" for the default section that serves at the root.With the explicit directory config above and a watch directory of docs, your files would look like:
docs/
guides/
index.mdx
getting-started.mdx
api-reference/
authentication.mdx
endpoints.mdx
sdks/
javascript.mdx
python.mdxEach section builds its own sidebar from the pages that belong to it. By default, pages are grouped by category and sorted by categoryOrder and order from frontmatter.
For explicit control, use navigation.json with the object format to define per-section navigation:
{
"": [
{ "label": "General", "links": [{ "slug": "", "title": "Getting Started" }] }
],
"platform": [
{ "label": "API", "links": [{ "slug": "platform/auth", "title": "Auth" }] }
]
}Keys are section slugs. The root section uses "". Sections without a key fall back to auto-generated navigation. See the Navigation page for the full format.
Doccupine checks these rules in order and uses the first match:
directory field.platform/ match a section with slug: "platform").section value matches a section label.section frontmatter - Doccupine auto-discovers sections from the frontmatter. Sections update live as you add or remove the section field from files.Pages in the default section (with slug: "") serve at the root:
/getting-started, /installation/api/authentication, /sdks/javascriptWhen a file is in a directory that matches its section slug, the directory is stripped so it doesn't appear twice. For example, platform/auth.mdx in the "Platform" section serves at /platform/auth, not /platform/platform/auth.
These two config files serve different purposes and complement each other:
You can use either one independently. sections.json without navigation.json gives you sections with auto-generated sidebars. navigation.json without sections.json gives you custom sidebar ordering with frontmatter-discovered sections (or no sections at all).
section and sectionOrder to a few pages to try it out. No config files needed.sectionLabel: "Your Label" to your index.mdx frontmatter. Defaults to "Docs" if omitted.sections.json gives full control.navigation.json to define custom sidebar ordering for specific sections.