Sidebar items
The Docusaurus sidebar supports multiple item types that let you organize and present documentation in a flexible way. Below are the supported item types:
- Doc: Link to a single doc page and associate it with a sidebar.
- Link: Link to any internal or external page.
- Category: Create a dropdown of sidebar items.
- Autogenerated: Automatically generate a sidebar slice based on the file system.
- HTML: Render pure HTML in the sidebar.
- Ref: Link to a doc page without participating in navigation generation.
Doc: link to a docβ
The doc
type links to a doc page and assigns that page to a sidebar.
type SidebarItemDoc =
| {
type: 'doc';
id: string;
label?: string;
key?: string;
className?: string;
customProps?: Record<string, unknown>;
}
| string; // shorthand
Example:
export default {
mySidebar: [
{
type: 'doc',
id: 'getting-started',
label: 'Getting Started',
},
// Shorthand syntax
'introduction',
],
};
Tip: Use
sidebar_label
orsidebar_custom_props
in the docβs front matter to override labels or add metadata.
Link: link to any pageβ
The link
type links to internal or external pages.
type SidebarItemLink = {
type: 'link';
label: string;
href: string;
description?: string;
key?: string;
className?: string;
customProps?: Record<string, unknown>;
};
Example:
export default {
linksSidebar: [
{
type: 'link',
label: 'Home',
href: '/',
},
{
type: 'link',
label: 'GitHub',
href: 'https://github.com',
},
],
};
HTML: render custom markupβ
The html
type renders custom HTML inside a sidebar <li>
element.
type SidebarItemHtml = {
type: 'html';
value: string;
defaultStyle?: boolean;
key?: string;
className?: string;
customProps?: Record<string, unknown>;
};
Example:
export default {
myHtmlSidebar: [
{
type: 'html',
value: '<strong>Core Concepts</strong>',
defaultStyle: true,
},
],
};
Category: create a hierarchyβ
The category
type groups related items and can be collapsible.
type SidebarItemCategory = {
type: 'category';
label: string;
items: SidebarItem[];
description?: string;
key?: string;
className?: string;
customProps?: Record<string, unknown>;
collapsible?: boolean;
collapsed?: boolean;
link?: SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndex;
};
Example:
export default {
docs: [
{
type: 'category',
label: 'Guides',
collapsible: true,
collapsed: false,
items: [
'creating-pages',
{
type: 'category',
label: 'Advanced',
items: ['versioning', 'i18n'],
},
],
},
],
};
Category linksβ
A category can link to:
- Generated index page β auto-creates an index listing all children.
link: {
type: 'generated-index',
title: 'Docusaurus Guides',
description: 'Overview of guides',
slug: '/category/guides',
}
- Doc link β link to a specific document.
link: { type: 'doc', id: 'introduction' }
Collapsible and expanded optionsβ
collapsible: false
β category is fixed open.collapsed: false
β expanded by default.
Global defaults can be configured in docusaurus.config.js
:
export default {
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
sidebarCollapsible: false,
sidebarCollapsed: false,
},
},
],
],
};
Using shorthandsβ
You can simplify definitions with doc and category shorthand.
Doc shorthandβ
export default {
sidebar: ['myDoc'],
};
Category shorthandβ
export default {
sidebar: {
'Getting Started': ['intro', 'setup'],
Guides: ['advanced'],
},
};
This shorthand allows nested categories:
export default {
sidebar: {
Docusaurus: {
Basics: ['intro', 'setup'],
Advanced: ['versioning', 'plugins'],
},
},
};
These options make Docusaurus sidebars flexible and powerful, letting you mix links, docs, categories, and even custom HTML to create rich navigation experiences.