Directory Structure

VuePress follows the principle of "Convention is better than configuration", the recommended document structure is as follows:

  1. .

  2. ├── docs

  3. ├── .vuepress (Optional)

  4. ├── components (Optional)

  5. ├── theme (Optional)

  6. └── Layout.vue

  7. ├── public (Optional)

  8. ├── styles (Optional)

  9. ├── index.styl

  10. └── palette.styl

  11. ├── templates (Optional, Danger Zone)

  12. ├── dev.html

  13. └── ssr.html

  14. ├── config.js (Optional)

  15. └── enhanceApp.js (Optional)

  16. ├── README.md

  17. ├── guide

  18. └── README.md

  19. └── config.md

  20. └── package.json

Note

Please note the capitalization of the directory name.

  • docs/.vuepress: It’s used to store global configuration, components, static resources, etc.
  • docs/.vuepress/components: The Vue components in this directory will be automatically registered as global components.
  • docs/.vuepress/theme: Used to store local theme.
  • docs/.vuepress/styles: Stores style related files.
  • docs/.vuepress/styles/index.styl: Automatically applied global style files, generated at the ending of the CSS file, have a higher priority than the default style.
  • docs/.vuepress/styles/palette.styl: The palette is used to override the default color constants and to set the color constants of Stylus.
  • docs/.vuepress/public: Static resource directory.
  • docs/.vuepress/templates: Store HTML template files.
  • docs/.vuepress/templates/dev.html: HTML template file for development environment.
  • docs/.vuepress/templates/ssr.html: Vue SSR based HTML template file in the built time.
  • docs/.vuepress/config.js: Entry file of configuration, can also be yml or toml.
  • docs/.vuepress/enhanceApp.js: App level enhancement.

Note

When customizing templates/ssr.html, or templates/dev.html, it’s best to edit it on the basis of the default template filesDirectory Structure - 图1, otherwise it may cause a build failure.

Default Page Routing

Here we take docs directory as the targetDir (See Command-line Interface), and all the "Relative Path" below are relative to docs directory. Add scripts in package.json that located in the project root directory:

  1. {
  2. "scripts": {
  3. "dev": "vuepress dev docs",
  4. "build": "vuepress build docs"
  5. }
  6. }

For the above directory structure, the default page routing paths are as follows:

Relative PathPage Routing
/README.md/
/guide/README.md/guide/
/config.md/config.html

Also see: