You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/default-theme-config/README.md
+28-12
Original file line number
Diff line number
Diff line change
@@ -146,45 +146,61 @@ Sidebar groups are collapsable by default. You can force a group to be always op
146
146
147
147
### Multiple Sidebars
148
148
149
-
If you wish to display different sidebars for different group of pages, first organize your pages into directories:
149
+
If you wish to display different sidebars for different sections of content, first organize your pages into directories for each desired section:
150
150
151
151
```
152
152
.
153
153
├─ README.md
154
-
├─ foo
154
+
├─ contact.md
155
+
├─ about.md
156
+
├─ foo/
155
157
│ ├─ README.md
156
158
│ ├─ one.md
157
159
│ └─ two.md
158
-
└─ bar
160
+
└─ bar/
159
161
├─ README.md
160
162
├─ three.md
161
163
└─ four.md
162
164
```
163
165
164
-
Then, with the following sidebar config:
166
+
Then, update your configuration to define your sidebar for each section.
165
167
166
168
```js
167
169
// .vuepress/config.js
168
170
module.exports= {
169
171
themeConfig: {
170
172
sidebar: {
171
-
// sidebar for pages under /foo/
172
173
'/foo/': [
173
-
'',
174
-
'one',
175
-
'two'
174
+
'',/* /foo/ */
175
+
'one',/* /foo/one.html */
176
+
'two'/* /foo/two.html */
176
177
],
177
-
// sidebar for pages under /bar/
178
+
178
179
'/bar/': [
179
-
'',
180
-
'three',
181
-
'four'
180
+
'', /* /bar/ */
181
+
'three', /* /bar/three.html */
182
+
'four'/* /bar/four.html */
183
+
],
184
+
185
+
// fallback
186
+
'/': [
187
+
'', /* / */
188
+
'contact', /* /contact.html */
189
+
'about'/* /about.html */
182
190
]
183
191
}
184
192
}
185
193
}
186
194
```
187
195
196
+
::: warning
197
+
Make sure to define the fallback configuration last.
198
+
199
+
VuePress checks each sidebar config from top to bottom. If the fallback configuration was first, VuePress would incorrectly match `/foo/` or `/bar/four.html` because they both start with `/`.
200
+
:::
201
+
202
+
203
+
188
204
### Auto Sidebar for Single Pages
189
205
190
206
If you wish to automatically generate a sidebar that contains only the header links for the current page, you can use `YAML front matter` on that page:
0 commit comments