Documentation Integration

Build a comprehensive help center and documentation site with hierarchical navigation.

The documentation system (help center) provides a structured knowledge base for your product. Documentation pages are organized hierarchically with automatic sidebar navigation, search integration, and breadcrumbs. Users access docs at /docs or /help, and content is managed through the same Keystatic CMS as blog posts. This documentation you're reading is built with the same system.

The documentation system is a hierarchical content structure that renders Markdoc pages with automatic navigation, designed for product guides, API references, and user onboarding.

  • Use documentation when: explaining how to use features, providing API references, creating step-by-step tutorials, or building a knowledge base that users reference repeatedly.
  • Use the blog when: publishing announcements, thought leadership, or content with a publication date that becomes "old" over time.
  • Use the FAQ when: answering common questions with short, direct answers that reduce support tickets.

Documentation Structure

Documentation is organized in apps/web/content/documentation/:

apps/web/content/documentation/
├── getting-started/
│ ├── getting-started.mdoc # Section overview (metadata file)
│ ├── installation.mdoc
│ └── quickstart.mdoc
├── guides/
│ ├── guides.mdoc # Section overview
│ ├── authentication.mdoc
│ └── organizations.mdoc
└── api/
├── api.mdoc # Section overview
└── reference.mdoc

Creating Sections

Sections are created automatically based on folder structure. Each section needs a metadata file that matches the folder name:

Option 1: File at same level as folder

content/documentation/
├── getting-started.mdoc # Metadata for getting-started/
└── getting-started/
├── installation.mdoc
└── quickstart.mdoc

Option 2: File inside folder with same name

content/documentation/
└── getting-started/
├── getting-started.mdoc # Metadata for this section
├── installation.mdoc
└── quickstart.mdoc

Section Metadata

The metadata file defines section properties:

---
title: "Getting Started"
description: "Learn how to get started with our product."
order: 1
status: "published"
collapsible: true
collapsed: false
---
This section covers installation and initial setup.
FieldTypeDescription
titlestringSection title in sidebar
descriptionstringSection description
ordernumberSort order (lower numbers first)
status"draft" | "published"Visibility
collapsiblebooleanCan section collapse in sidebar
collapsedbooleanInitial collapsed state

Page Frontmatter

Individual documentation pages use this frontmatter:

---
title: "Installation"
label: "Installation"
description: "Step-by-step installation guide."
order: 1
status: "published"
---
FieldRequiredDescription
titleYesPage title (in browser tab, breadcrumbs)
labelNoShorter label for sidebar (defaults to title)
descriptionYesMeta description for SEO
orderNoSort order within section (default: 0)
statusYes"draft" or "published"

The documentation system automatically generates:

  • Sidebar navigation based on folder structure and order values
  • Breadcrumbs showing the current location hierarchy
  • Previous/Next links at the bottom of each page
  • Table of contents from page headings (H2, H3)

Customizing Order

Control page order with the order field. Lower numbers appear first:

# installation.mdoc - appears first
order: 1
# quickstart.mdoc - appears second
order: 2
# advanced-setup.mdoc - appears last
order: 3

Pages without an order field default to 0 and are sorted alphabetically.

Custom Markdoc Components

Documentation supports these built-in Markdoc components:

Alert

{% alert type="default" title="Note" %}
This is an informational callout.
{% /alert %}
{% alert type="warning" title="Warning" %}
Be careful with this operation.
{% /alert %}
{% alert type="error" title="Error" %}
This action cannot be undone.
{% /alert %}

Code Blocks with Titles

```typescript
### Tabs
```markdown

Linking Between Pages

Use relative links to connect documentation pages:

See the [installation guide](./installation) for setup steps.
For advanced configuration, check [environment variables](../configuration/environment-variables).
Related: [Authentication overview](../../authentication/overview)

Search Integration

Documentation pages are automatically indexed for the built-in search. Ensure pages have:

  • Descriptive title and description in frontmatter
  • Clear heading hierarchy (H2, H3)
  • Keywords in the first paragraph

Common Pitfalls

  • Missing section metadata: Folders without a matching metadata file won't appear in navigation. Create a file named after the folder.
  • Orphan pages: Pages not in a section folder may not appear in the sidebar. Organize all pages within sections.
  • Broken relative links: Test links after restructuring. Moving a file breaks incoming relative links.
  • Inconsistent order values: Gaps in order numbers are fine, but missing order values cause alphabetical sorting within that group.
  • Draft pages in navigation: Draft pages (status: "draft") still appear in the admin UI but not on the public site. Don't forget to publish.
  • Deeply nested sections: More than 3 levels of nesting becomes hard to navigate. Restructure if sections go deeper.
  • Large pages: Break pages over 2000 words into multiple pages. Users scan documentation; they don't read it linearly.

Frequently Asked Questions

How do I add a new documentation section?
Create a new folder in content/documentation/ and add a metadata file with the same name as the folder. Then add page files inside the folder.
Can I have documentation at multiple URLs?
Yes. Create multiple documentation roots by adding routes in app/[locale]/(public)/. Each can point to different content directories.
How do I add images to documentation?
Store images in public/images/docs/ and reference with absolute paths like /images/docs/screenshot.webp. Use descriptive filenames.
Can I embed videos in documentation?
Yes. Use standard Markdoc or create a custom Video component. For YouTube, use an iframe with the embed URL.
How do I redirect old documentation URLs?
Add redirects in next.config.js using the redirects() function. Map old paths to new paths with permanent: true.
Is documentation content searchable?
Yes. The built-in search indexes all published documentation pages. Ensure pages have descriptive titles and descriptions for best results.

Next: Changelog →