Add New Category
This page shows you how to add a new category to Nocturne's sidebar.
Important: Decap CMS cannot create categories. You must do this manually in code.
Estimated time: 3 minutes.
What Is a Category?
A category is a group of docs in the sidebar. Examples in Nocturne:
- Getting Started
- Configuration
- Customization
- Developer Guide
Each category maps to a folder in docs/.
The 3 Steps
- Create the folder in
docs/ - Create
_category_.jsoninside the folder - Add the category to
sidebars.ts
Step 1 — Create the Folder
In docs/, create a new folder:
mkdir docs/tutorials
Folder name: Use lowercase with hyphens. Example: tutorials, api-reference, advanced-guides.
Step 2 — Create _category_.json
Inside the new folder, create _category_.json:
File: docs/tutorials/_category_.json
{
"label": "Tutorials",
"position": 5,
"collapsed": false,
"link": {
"type": "generated-index",
"title": "Tutorials",
"description": "Step-by-step tutorials for Nocturne."
}
}
| Field | Purpose |
|---|---|
label | Category name in the sidebar |
position | Order (1, 2, 3...) |
collapsed | false = open, true = closed |
link.type | generated-index or doc |
link.title | Title for generated index page |
link.description | Description for generated index |
Note: If you use a manual sidebars.ts, position is ignored — the order in sidebars.ts wins.
Step 3 — Add to sidebars.ts
Open sidebars.ts and add the new category:
{
type: 'category',
label: 'Tutorials',
collapsed: false,
link: {
type: 'doc',
id: 'tutorials/index',
},
items: [
'tutorials/index',
'tutorials/first-tutorial',
'tutorials/second-tutorial',
],
},
Add it in the position you want. Order matters.
Step 4 — Add the Index Page
If you want an index page for the category, create:
File: docs/tutorials/index.md
---
sidebar_position: 1
sidebar_label: Overview
title: "Tutorials — Overview"
description: "Step-by-step tutorials for Nocturne."
---
# Tutorials
Intro text for this category.
## What You'll Learn
- Tutorial 1
- Tutorial 2
## What's Next?
👉 [Next: First Tutorial →](/docs/tutorials/first-tutorial)
Step 5 — Add the First Tutorial
File: docs/tutorials/first-tutorial.md
---
sidebar_position: 2
sidebar_label: First Tutorial
title: "First Tutorial — Example"
description: "An example tutorial."
---
# First Tutorial
Content here.
Step 6 — Restart the Dev Server
npm start
The new category appears in the sidebar.
Full Example
Folder structure:
docs/
└── tutorials/
├── _category_.json
├── index.md
├── first-tutorial.md
└── second-tutorial.md
docs/tutorials/_category_.json:
{
"label": "Tutorials",
"position": 5,
"collapsed": false,
"link": {
"type": "doc",
"id": "tutorials/index"
}
}
sidebars.ts:
{
type: 'category',
label: 'Tutorials',
collapsed: false,
link: {
type: 'doc',
id: 'tutorials/index',
},
items: [
'tutorials/index',
'tutorials/first-tutorial',
'tutorials/second-tutorial',
],
},
Category Link Types
Two ways to link a category:
Type 1 — generated-index
Auto-generates an index page listing all docs in the category.
{
"link": {
"type": "generated-index",
"title": "Tutorials",
"description": "Step-by-step tutorials."
}
}
Pros: No need to write an index.md.
Cons: Less control over the index page.
Type 2 — doc
Links to a custom index.md.
{
"link": {
"type": "doc",
"id": "tutorials/index"
}
}
Pros: Full control over the index page.
Cons: Need to write an index.md.
Nocturne uses doc for most categories — more control.
Adding Categories via Decap CMS
Decap CMS cannot create categories. This is a known limitation.
Why: Decap CMS edits content, not config files. _category_.json and sidebars.ts are config.
Workaround: Add the category manually in code, then edit content via CMS.
See Decap CMS → Adding a New Category for details.
Troubleshooting
Category doesn't appear
- Check that
_category_.jsonis inside the folder - Check that the folder is in
docs/ - Check that the category is added to
sidebars.ts - Restart the dev server
"These sidebar document ids do not exist"
- Check the doc ID — must match file path without
.md - Check that all
itemsin the category exist - Check for typos
Category is not clickable
Add a link field to the category in sidebars.ts.
Category appears in the wrong order
The order in sidebars.ts wins. Move the category object to the right position.
New docs don't appear in the category
- Check that they're in the
itemsarray - Check that the doc IDs are correct
- Restart the dev server
Deleting a Category
- Remove the category from
sidebars.ts - Delete the folder in
docs/ - Restart the dev server
Warning: Docs inside the folder are deleted too. Move them elsewhere first if needed.
What's Next?
You've completed the Developer Guide.