Auto Sidebar Frontmatter
This page documents the canonical frontmatter contract consumed by the sidebar engine in docs/.vitepress/utils/sidebar.
Why This Matters
The sidebar system is declarative-first:
index.mdand page frontmatter define structure intent.- Sidebar generator builds the tree.
- JSON overrides under
docs/.vitepress/config/sidebar/**are now reserved for labels and view state only.
Use this page as the source-of-truth when building content templates, snippets, and extension completions.
Frontmatter-First Policy (Current)
- Sidebar ordering is controlled by frontmatter
priorityonindex.mdand leaf*.mdpages. - Page
descriptionis documented in frontmatter (for docs metadata and extension generation). order.jsonis kept empty by default so it does not override frontmatter priorities.
Directory-Level Keys (index.md)
| Key | Type | Default | Effect |
|---|---|---|---|
root | boolean | false | Marks the directory as an independent sidebar root route. |
title | string | directory name | Sidebar label for this directory/root. |
description | string | empty | Metadata summary for docs/extension tooling. |
hidden | boolean | false | Hides this directory from sidebar output. |
priority | number | 0 | Lower numbers sort earlier. |
maxDepth | number | 3 | Maximum recursive depth for generated items. |
collapsed | boolean | false | Default collapsed state for this directory group. |
itemOrder | `string[] | Record<string, number>` | {} |
groups | GroupConfig[] | [] | Extracts subpaths into generated group sections. |
externalLinks | ExternalLinkConfig[] | [] | Adds external links in the same section. |
Page-Level Keys (*.md)
| Key | Type | Default | Effect |
|---|---|---|---|
title | string | filename | Sidebar page label. |
description | string | empty | Page summary metadata for docs tooling. |
hidden | boolean | false | Hides this page from sidebar output. |
priority | number | 0 | Sorting value among sibling pages (frontmatter authority). |
Root Section Example
yaml
---
title: Hero Playground
layout: doc
root: true
maxDepth: 6
collapsed: false
---Nested Root (Root Inside Root) Example
Use root: true in a child section index.md to create deeper sidebar route scopes.
yaml
# /hero/index.md
---
title: Hero Playground
root: true
maxDepth: 6
---
# /hero/matrix/index.md
---
title: Hero Config Matrix
root: true
maxDepth: 5
priority: 10
---Group + External Links Example
yaml
---
title: Platform Docs
root: true
groups:
- title: API Modules
path: api/modules
priority: 10
maxDepth: 4
externalLinks:
- text: Internal Dashboard
link: https://example.com/dashboard
priority: 50
---Optional itemOrder Example
yaml
---
title: Frontmatter System
itemOrder:
hero-runtime.md: 1
sidebar-auto-system.md: 2
key-inventory.md: 3
---JSON Override Layer
The engine synchronizes generated structure with JSON files under:
docs/.vitepress/config/sidebar/<lang>/<section>/locales.jsondocs/.vitepress/config/sidebar/<lang>/<section>/collapsed.jsondocs/.vitepress/config/sidebar/<lang>/<section>/hidden.json
order.json exists for compatibility, but in this project it is intentionally kept empty and should not be used as the primary ordering source.
Use declarative frontmatter for long-term structure intent.
Regeneration Commands
bash
cd docs
yarn sidebarBuild pipeline:
bash
cd docs
yarn locale
yarn sidebar
yarn tags
yarn buildTroubleshooting
If sidebar output looks stale:
- Ensure the section has an
index.mdwithroot: true. - Re-run
yarn sidebar. - Check
docs/.vitepress/cache/sidebar/sidebar_<lang>.jsonfor generated routes. - Verify
priorityvalues directly in markdown frontmatter before touching sidebar JSON files.