Default Theme Config

TIP

All options listed on this page apply to the default theme only. If you are using a custom theme, the options may be different.

Homepage

The default theme provides a homepage layout (used on the homepage of this site). To use it, specify home: true plus some other metadata in your root README.md's YAML frontmatter. This is an example of how it works:

  1. ---
  2. home: true
  3. heroImage: /hero.png
  4. heroText: Hero Title
  5. tagline: Hero subtitle
  6. actionText: Get Started
  7. actionLink: /guide/
  8. features:
  9. - title: Simplicity First
  10. details: Minimal setup with markdown-centered project structure helps you focus on writing.
  11. - title: Vue-Powered
  12. details: Enjoy the dev experience of Vue + webpack, use Vue components in markdown, and develop custom themes with Vue.
  13. - title: Performant
  14. details: VuePress generates pre-rendered static HTML for each page, and runs as an SPA once a page is loaded.
  15. footer: MIT Licensed | Copyright © 2018-present Evan You
  16. ---

You can disable title and subtitle by setting the corresponding field to null.

Any extra content after the YAML front matter will be parsed as normal Markdown and rendered after the features section.

To use a fully custom homepage layout, you can also use a Custom Layout.

Navbar

The Navbar may contain your page title, Search Box, Navbar Links, Languages and Repository Link, they all depend on your configuration.

You can add a logo to the navbar via themeConfig.logo. Logo can be placed in public folder.

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. logo: '/assets/img/logo.png',
  5. }
  6. }

You can add links to the navbar via themeConfig.nav:

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. nav: [
  5. { text: 'Home', link: '/' },
  6. { text: 'Guide', link: '/guide/' },
  7. { text: 'External', link: 'https://google.com' }
  8. ]
  9. }
  10. }

Outbound links automatically get target="_blank" rel="noopener noreferrer". You can offer target and rel to customize the attributes:

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. nav: [
  5. { text: 'External', link: 'https://google.com', target:'_self', rel:'' },
  6. { text: 'Guide', link: '/guide/', target:'_blank' }
  7. ]
  8. }
  9. }

These links can also be dropdown menus if you provide an array of items instead of a link:

  1. module.exports = {
  2. themeConfig: {
  3. nav: [
  4. {
  5. text: 'Languages',
  6. ariaLabel: 'Language Menu',
  7. items: [
  8. { text: 'Chinese', link: '/language/chinese/' },
  9. { text: 'Japanese', link: '/language/japanese/' }
  10. ]
  11. }
  12. ]
  13. }
  14. }

You can also have sub groups inside a dropdown by having nested items:

  1. module.exports = {
  2. themeConfig: {
  3. nav: [
  4. {
  5. text: 'Languages',
  6. items: [
  7. { text: 'Group1', items: [/* */] },
  8. { text: 'Group2', items: [/* */] }
  9. ]
  10. }
  11. ]
  12. }
  13. }

Disable the Navbar

To disable the navbar globally, use themeConfig.navbar:

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. navbar: false
  5. }
  6. }

You can disable the navbar for a specific page via YAML front matter:

  1. ---
  2. navbar: false
  3. ---

Sidebar

To enable the sidebar, use themeConfig.sidebar. The basic configuration expects an Array of links:

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. sidebar: [
  5. '/',
  6. '/page-a',
  7. ['/page-b', 'Explicit link text']
  8. ]
  9. }
  10. }

You can omit the .md extension, and paths ending with / are inferred as */README.md. The text for the link is automatically inferred (either from the first header in the page or explicit title in YAML front matter). To explicitly specify the link text, use an array in form of [link, text].

The sidebar automatically displays links for headers in the current active page, nested under the link for the page itself. You can customize this behavior using themeConfig.sidebarDepth. The default depth is 1, which extracts the h2 headers. Setting it to 0 disables the header links, and the max value is 2 which extracts both h2 and h3 headers.

A page can also override this value via YAML front matter:

  1. ---
  2. sidebarDepth: 2
  3. ---

The sidebar only displays links for headers in the current active page. You can display all header links for every page with themeConfig.displayAllHeaders: true:

  1. module.exports = {
  2. themeConfig: {
  3. displayAllHeaders: true // Default: false
  4. }
  5. }

By default, the nested header links and the hash in the URL are updated as the user scrolls to view the different sections of the page. This behavior can be disabled with the following theme config:

  1. module.exports = {
  2. themeConfig: {
  3. activeHeaderLinks: false, // Default: true
  4. }
  5. }

TIP

It’s worth mentioning that when you disable this option, the corresponding script of this functionality will not be loaded. This is a small point in our performance optimization.

Sidebar Groups

You can divide sidebar links into several groups by using objects:

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. sidebar: [
  5. {
  6. title: 'Group 1', // required
  7. path: '/foo/', // optional, which should be a absolute path.
  8. collapsable: false, // optional, defaults to true
  9. sidebarDepth: 1, // optional, defaults to 1
  10. children: [
  11. '/'
  12. ]
  13. },
  14. {
  15. title: 'Group 2',
  16. children: [ /* ... */ ]
  17. }
  18. ]
  19. }
  20. }

Sidebar groups are collapsable by default. You can force a group to be always open with collapsable: false.

A sidebar group config also supports sidebarDepth field to override the default sidebar depth (1).

TIP

Nested sidebar group beta is also supported, but the nesting depth should be less than 3, otherwise the console will receive a warning.

Multiple Sidebars

To display different sidebars for different sections of content, first organize your pages into directories for each desired section:

  1. .
  2. ├─ README.md
  3. ├─ contact.md
  4. ├─ about.md
  5. ├─ foo/
  6. ├─ README.md
  7. ├─ one.md
  8. └─ two.md
  9. └─ bar/
  10. ├─ README.md
  11. ├─ three.md
  12. └─ four.md

Then, update your configuration to define your sidebar for each section.

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. sidebar: {
  5. '/foo/': [
  6. '', /* /foo/ */
  7. 'one', /* /foo/one.html */
  8. 'two' /* /foo/two.html */
  9. ],
  10. '/bar/': [
  11. '', /* /bar/ */
  12. 'three', /* /bar/three.html */
  13. 'four' /* /bar/four.html */
  14. ],
  15. // fallback
  16. '/': [
  17. '', /* / */
  18. 'contact', /* /contact.html */
  19. 'about' /* /about.html */
  20. ]
  21. }
  22. }
  23. }

WARNING

Make sure to define the fallback configuration last.

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 /.

Auto Sidebar for Single Pages

To automatically generate a sidebar that contains only the header links for the current page, you can use YAML front matter on that page:

  1. ---
  2. sidebar: auto
  3. ---

You can also enable it in all pages by using config:

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. sidebar: 'auto'
  5. }
  6. }

In multi-language mode, you can also apply it to a specific locale:

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. '/': {
  5. sidebar: 'auto'
  6. }
  7. }
  8. }

Disabling the Sidebar

You can disable the sidebar on a specific page with YAML front matter:

  1. ---
  2. sidebar: false
  3. ---

You can disable the built-in search box with themeConfig.search: false, and customize how many suggestions will be shown with themeConfig.searchMaxSuggestions:

  1. module.exports = {
  2. themeConfig: {
  3. search: false,
  4. searchMaxSuggestions: 10
  5. }
  6. }

You can also disable the built-in search box for individual pages with YAML front matter:

  1. ---
  2. search: false
  3. ---

TIP

Built-in Search only builds index from the title, h2 and h3 headers, if you need full text search, you can use Algolia DocSearch.

Algolia DocSearch

The themeConfig.algolia option allows you to use Algolia DocSearchDefault Theme Config - 图1 to replace the simple built-in search. To enable it, you need to provide at least apiKey and indexName:

  1. module.exports = {
  2. themeConfig: {
  3. algolia: {
  4. apiKey: '<API_KEY>',
  5. indexName: '<INDEX_NAME>'
  6. }
  7. }
  8. }

Note

Unlike the built-in search engine which works out of the box, Algolia DocSearchDefault Theme Config - 图2 requires you to submit your site to them for indexing before it starts working.

For more options, check out Algolia DocSearch’s documentationDefault Theme Config - 图3.

Search Placeholder

You can define a placeholder for the search box by adding the searchPlaceholder attribute:

  1. module.exports = {
  2. themeConfig: {
  3. searchPlaceholder: 'Search...'
  4. }
  5. }

Last Updated

The themeConfig.lastUpdated option allows you to get the UNIX timestamp(ms) of each file’s last git commit, and it will also display at the bottom of each page in an appropriate format:

  1. module.exports = {
  2. themeConfig: {
  3. lastUpdated: 'Last Updated', // string | boolean
  4. }
  5. }

Note that it’s off by default. If given a string, it will be displayed as a prefix (default value: Last Updated).

WARNING

Since lastUpdated is based on git, you can only use it in a git repository. Also, since the timestamp used comes from the git commit, it will display only after a first commit for a given page, and update only on ensuing commits of that page.

Also see:

Prev and next links are automatically inferred based on the sidebar order of the active page.

You can disable them globally with themeConfig.nextLinks and themeConfig.prevLinks:

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. // default value is true. Set it to false to hide next page links on all pages
  5. nextLinks: false,
  6. // default value is true. Set it to false to hide prev page links on all pages
  7. prevLinks: false
  8. }
  9. }

You can also explicitly overwrite or disable them for individual pages with YAML front matter:

  1. ---
  2. prev: ./some-other-page
  3. next: false
  4. ---

Providing themeConfig.repo auto generates a GitHub link in the navbar and "Edit this page" links at the bottom of each page.

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. // Assumes GitHub. Can also be a full GitLab url.
  5. repo: 'vuejs/vuepress',
  6. // Customising the header label
  7. // Defaults to "GitHub"/"GitLab"/"Bitbucket" depending on `themeConfig.repo`
  8. repoLabel: 'Contribute!',
  9. // Optional options for generating "Edit this page" link
  10. // if your docs are in a different repo from your main project:
  11. docsRepo: 'vuejs/vuepress',
  12. // if your docs are not at the root of the repo:
  13. docsDir: 'docs',
  14. // if your docs are in a specific branch (defaults to 'master'):
  15. docsBranch: 'master',
  16. // defaults to false, set to true to enable
  17. editLinks: true,
  18. // custom text for edit link. Defaults to "Edit this page"
  19. editLinkText: 'Help us improve this page!'
  20. }
  21. }

You can overwrite the following properties on specific pages via YAML front matter:

  1. ---
  2. editLink: false # Will overwrite 'editLinks' from themeConfig
  3. prev: true # Will overwrite 'prevLinks' property from themeConfig
  4. next: ./my-next-page # Will overwrite 'nextLinks' property from themeConfig
  5. ---

Smooth Scrolling 1.2.0+

The themeConfig.smoothScroll option allows you to enable smooth scrolling.

  1. // .vuepress/config.js
  2. module.exports = {
  3. themeConfig: {
  4. smoothScroll: true
  5. }
  6. }

Custom Page Class

Sometimes, you may need to add a unique class for a specific page so that you can target content on that page only in custom CSS. You can add a class to the theme container div with pageClass in YAML front matter:

  1. ---
  2. pageClass: custom-page-class
  3. ---

Then you can write CSS targeting that page only in ./vuepress/styles/index.styl.

  1. .theme-container.custom-page-class {
  2. /* page-specific rules */
  3. }

Note

These styles are written in index.styl, a file that allows you to conveniently add extra styles or override existing ones for the default theme.

Custom Layout for Specific Pages

By default the content of each *.md file is rendered in a <div class="page"> container, along with the sidebar, auto-generated edit links and prev/next links. To use a fully custom component in place of the page, you can again specify the component to use using YAML front matter:

  1. ---
  2. layout: SpecialLayout
  3. ---

This will render .vuepress/components/SpecialLayout.vue for the given page.

Ejecting

You can copy the default theme source code into .vuepress/theme to fully customize the theme using the vuepress eject [targetDir] command.

WARNING

Once you eject, you are on your own and won’t be receiving future updates or bugfixes to the default theme even if you upgrade VuePress.