To create a new top-level navigation item in the documentation, follow these steps:
-
Create a New Folder: Inside the
docs/
directory, create a new folder with a name that represents your new section. For example, if your new section is named "New Section Name," create a folder namednew-section-name
. -
Add Content: Within the newly created folder, add an
index.md
file. This Markdown file will contain the content for your new section. -
Make it visible inside of sidebar: Open
docs/.vitepress/config.js
in your code editor, locate thethemeConfig.sidebar
object. Add a new item to this object with the following format:themeConfig: { // ... sidebar: [ // existing sidebar items { text: 'New Section Name', link: '/new-section-name/', }, // existing sidebar items ] // ... }
-
Update the Table of Contents: Open
docs/index.md
, which is the main documentation file. Update the table of contents to include a link to your new section.
To create nested navigation in the documentation sidebar you should have the next structure inside of
themeConfig.sidebar
(docs/.vitepress/config.js
):
themeConfig: {
// ...
sidebar: [
// existing sidebar items
{
text: 'New Section Name',
items: [
{ text: 'New Subsection 1', link: '/subsection-1' },
{ text: 'New Subsection 2', link: '/subsection-2' },
]
},
// existing sidebar items
]
// ...
}
For more docs, please visit vitepress.dev