Using multiple sidebars
You can create a sidebar for each set of Markdown files that you want to group together.
Consider this example:
export default {
tutorialSidebar: {
'Category A': ['doc1', 'doc2'],
},
apiSidebar: ['doc3', 'doc4'],
};
When browsing doc1
or doc2
, the tutorialSidebar
will be displayed; when browsing doc3
or doc4
, the apiSidebar
will be displayed.
Understanding sidebar association
Following the example above, if a commonDoc
is included in both sidebars:
export default {
tutorialSidebar: {
'Category A': ['doc1', 'doc2', 'commonDoc'],
},
apiSidebar: ['doc3', 'doc4', 'commonDoc'],
};
How does Docusaurus know which sidebar to display when browsing commonDoc
? Answer: it doesn't, and we don't guarantee which sidebar it will pick.
When you add doc Y to sidebar X, it creates a two-way binding: sidebar X contains a link to doc Y, and when browsing doc Y, sidebar X will be displayed. But sometimes, we want to break either implicit binding:
- How do I generate a link to doc Y in sidebar X without making sidebar X displayed on Y? For example, when I include doc Y in multiple sidebars as in the example above, and I want to explicitly tell Docusaurus to display one sidebar?
- How do I make sidebar X displayed when browsing doc Y, but sidebar X shouldn't contain the link to Y? For example, when Y is a "doc home page" and the sidebar is purely used for navigation?
Front matter option displayed_sidebar
will forcibly set the sidebar association. For the same example, you can still use doc shorthands without any special configuration:
export default {
tutorialSidebar: {
'Category A': ['doc1', 'doc2'],
},
apiSidebar: ['doc3', 'doc4'],
};
And then add a front matter:
---
displayed_sidebar: apiSidebar
---