Autogenerated sidebars
An explicit sidebar lists every page by hand. For large or fast-changing docs, let DocsLit build it from the folders in docs/. New pages appear automatically, which suits teams and AI agents that add pages often.
You can generate the whole sidebar, or only some groups.
Generate the whole sidebar
Set sidebar to the string "auto":
- Pages directly in
docs/go into one group named after your sitename. - Each top-level folder becomes a group. Its label is the folder name in title case, so
getting-startedbecomes "Getting Started". - Deeper folders become nested subgroups.
- Folders with no pages, and any file or folder that starts with
_or., are skipped.
Start without a config file
When a project has no docslit.json, DocsLit uses an automatic sidebar, the same as "sidebar": "auto", and takes the site name from the folder name. Add a docslit.json later to set a name or an explicit sidebar. Commands that edit the config, such as docslit new and docslit theme use, need a real docslit.json.
Generate one group
Add autogenerate to a group in an otherwise explicit sidebar. Explicit pages come first, then the generated ones:
autogenerate takes a folder under docs/, or an object with directory and collapsed. A page that you list explicitly anywhere in the sidebar is not generated a second time. A bad folder, or one with no pages, produces a warning at build time.
Order pages
Within a folder, DocsLit sorts like this:
- Items with
sidebar_positioncome first, lowest number first. Pages and subfolders share the same numbers. - Then
index,introductionandoverviewpages. - Then other pages by file name.
- Then subgroups by folder name.
Set the position in a page's frontmatter:
Labels and hiding
A page's sidebar label is its frontmatter title. Hide a page from a generated sidebar with sidebar: false:
A hidden page still builds and is reachable by URL. validate does not report it as an orphan.
Configure a folder with _category.json
Put a _category.json file in a folder to set its group label, position and collapsed state:
sidebar_position on a page.collapsed value of the parent autogenerate.Invalid JSON in a _category.json file is ignored with a warning. The file is read for subfolders. To label the top-level folder of an autogenerate source, use the group name in docslit.json.
Collapsible groups
Any sidebar group, explicit or generated, can collapse. Add a boolean collapsed:
collapsed: true starts the group closed and collapsed: false starts it open. Groups without the key stay plain, always-open headings.
The group that contains the current page always opens, and a search filter opens matching groups. When a reader opens or closes a group, DocsLit remembers the choice in their browser.
Add pages to an autogenerated sidebar
docslit new does not edit the sidebar when the page falls under an autogenerated source. It reports "autogenerated": true and the page appears on its own. docslit dev rebuilds the sidebar when you add, remove or rename pages, change sidebar_position, or edit a _category.json.
Autogeneration also works with versions and with per-locale sidebars in sidebars.