Default Theme: Sidebar
Configure the sidebar navigation for your VitePress site.
Basic Sidebar
The sidebar is the main navigation component. You can configure it via themeConfig.sidebar
.
js
export default {
themeConfig: {
sidebar: [
{
text: 'Guide',
items: [
{ text: 'Introduction', link: '/introduction' },
{ text: 'Getting Started', link: '/getting-started' }
]
}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Multiple Sidebars
You can define different sidebars for different sections:
js
export default {
themeConfig: {
sidebar: {
'/guide/': [
{
text: 'Guide',
items: [
{ text: 'Introduction', link: '/guide/introduction' },
{ text: 'Getting Started', link: '/guide/getting-started' }
]
}
],
'/config/': [
{
text: 'Config',
items: [
{ text: 'Introduction', link: '/config/introduction' },
{ text: 'App Config', link: '/config/app-config' }
]
}
]
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Collapsible Sidebar Groups
Make sidebar groups collapsible:
js
export default {
themeConfig: {
sidebar: [
{
text: 'Guide',
collapsed: false,
items: [
{ text: 'Introduction', link: '/introduction' },
{ text: 'Getting Started', link: '/getting-started' }
]
},
{
text: 'Advanced',
collapsed: true,
items: [
{ text: 'Advanced Config', link: '/advanced-config' },
{ text: 'Custom Theme', link: '/custom-theme' }
]
}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Auto Sidebar
Generate sidebar automatically from directory structure:
js
import { generateSidebar } from 'vitepress-sidebar'
export default {
themeConfig: {
sidebar: generateSidebar({
documentRootPath: 'docs',
scanStartPath: null,
resolvePath: '/docs/',
useTitleFromFileHeading: true,
useTitleFromFrontmatter: true,
frontmatterTitleFieldName: 'title',
useFolderTitleFromIndexFile: false,
useFolderLinkFromIndexFile: false,
hyphenToSpace: true,
underscoreToSpace: true,
capitalizeFirst: false,
capitalizeEachWords: false,
collapsed: true,
collapseDepth: 2,
sortMenusByName: false,
sortMenusByFrontmatterOrder: false,
sortMenusByFrontmatterDate: false,
sortMenusOrderByDescending: false,
sortMenusOrderNumericallyFromTitle: false,
sortMenusOrderNumericallyFromLink: false,
frontmatterOrderDefaultValue: 0,
manualSortFileNameByPriority: ['first.md', 'second', 'third.md'],
removePrefixAfterOrdering: false,
prefixSeparator: '.',
excludeFiles: ['first.md', 'secret.md'],
excludeFilesByFrontmatterFieldName: 'exclude',
excludeFolders: ['secret-folder'],
excludeFoldersFromIndex: ['assets', 'public', 'resources'],
includeDotFiles: false,
includeRootIndexFile: false,
includeFolderIndexFile: false,
includeEmptyFolder: false,
rootGroupText: 'Contents',
rootGroupLink: 'https://github.com/jooy2',
rootGroupCollapsed: false,
convertSameNameSubFileToGroupIndexPage: false,
folderLinkNotIncludesFileName: false,
keepMarkdownSyntaxFromTitle: false,
debugPrint: false,
})
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Sidebar Item Options
Basic Item
js
{ text: 'Introduction', link: '/introduction' }
1
Item with Active Match
js
{
text: 'Introduction',
link: '/introduction',
activeMatch: '/introduction'
}
1
2
3
4
5
2
3
4
5
External Link
js
{
text: 'GitHub',
link: 'https://github.com/vuejs/vitepress'
}
1
2
3
4
2
3
4
Group with Items
js
{
text: 'Group Title',
items: [
{ text: 'Item 1', link: '/item-1' },
{ text: 'Item 2', link: '/item-2' }
]
}
1
2
3
4
5
6
7
2
3
4
5
6
7