You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vuepress多侧边栏配置异常:仅显示首个路径侧边栏项

Troubleshooting VuePress 1.x Multi-Sidebar Not Showing Up

Hey there! Let's figure out why only your first sidebar is working while the others aren't. Based on your config and setup details, here are the most likely fixes to try:

1. Double-Check Your File Structure

First, make sure your project's file structure perfectly matches the sidebar paths you've defined. VuePress maps sidebar entries to actual markdown files, so if the files are in the wrong place, the sidebar won't populate. Your structure should look like this:

docs/
├── foo/
│   ├── index.md   # Maps to "/foo/" (the "" entry in your config)
│   └── one.md     # Maps to "/foo/one" (the "one" entry)
├── bar/
│   ├── index.md   # Maps to "/bar/" (the "" entry)
│   └── three.md   # Maps to "/bar/three" (the "three" entry)
└── index.md       # Maps to "/" (fallback entry)

If your bar/ folder is missing index.md or three.md, or if they're nested in another subfolder, the sidebar won't find them.

2. Verify Path Matching & Priority

In VuePress 1.x, sidebar object keys are processed in order, so more specific paths should come before generic ones (you already have this right with /foo/ and /bar/ before /). But make sure:

  • The trailing slash in your path keys (/foo/, /bar/) matches your actual page URLs. VuePress automatically renders foo/index.md as /foo/, so omitting the trailing slash (like /foo) will break the match.
  • Your page URLs exactly align with the config. For example, if you access /bar/three instead of /bar/three.html, the config still works, but ensure there's no typo in the file name (like 3.md instead of three.md).

3. Clear VuePress Cache

Old cache can sometimes prevent new config changes from taking effect. Try these steps:

  • Stop your running vuepress dev server
  • Delete the node_modules/.cache/vuepress folder
  • Restart the dev server with vuepress dev

4. Check Page Frontmatter for Overrides

If your bar/ pages have custom frontmatter settings that disable the sidebar, that'll override your global config. Open bar/three.md and bar/index.md to make sure there's no line like:

---
sidebar: false  # This hides the sidebar for the page
---

If you see this, remove it or set it to true to use the global sidebar.

5. Try Explicit Sidebar Configuration (Optional)

If the above fixes don't work, switch to a more explicit sidebar format to eliminate any ambiguity. Update your config like this:

module.exports = {
  title: "Jhonatan Morais",
  description: "Welcome to my documentation site",
  editLinks: true,
  smoothScroll: true,
  themeConfig: {
    sidebar: {
      "/foo/": [
        { title: "Foo Home", path: "/foo/" },
        { title: "One", path: "/foo/one" }
      ],
      "/bar/": [
        { title: "Bar Home", path: "/bar/" },
        { title: "Three", path: "/bar/three" }
      ],
      "/": [{ title: "Home", path: "/" }]
    }
  },
  postcss: {
    plugins: [require("autoprefixer"), require("tailwindcss")("./tailwind.js")],
  },
};

This explicitly ties each sidebar entry to a path and title, which can resolve subtle matching issues.


内容的提问来源于stack exchange,提问作者Jhonatan Morais

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 09:43:14