Skip to content

Plugins

The theme is a layout layer: the navbar, the sidebar, the document page, the home page and the not-found page are provided by the theme, while every feature outside the layout is provided by a plugin. The theme wires those plugins for you, with sensible defaults, so a typical site never installs or configures them itself.

The theme data plugin is always enabled and is not configurable, because the whole theme configuration is delivered to the client through it. Every other plugin can be switched in themePlugins.

Wired plugins

PluginthemePlugins keyDefaultNotes
@vuepress/plugin-theme-data—enabledAlways enabled.
@vuepress/plugin-copy-codecopyCodetrueScoped to the code blocks in the page content.
@vuepress/plugin-gitgittrueCollects the last updated time and the contributors.
@vuepress/plugin-active-header-linksactiveHeaderLinkstrueKeeps the URL hash in sync with the outline.
@vuepress/plugin-back-to-topbackToToptrueThe back to top button.
@vuepress/plugin-iconicontrueIconify assets, loaded at runtime.
@vuepress/plugin-medium-zoommediumZoomtrueImage zoom on the document images.
@vuepress/plugin-nprogressnprogresstrueThe progress bar on navigation.
@vuepress/plugin-seoseotrueOnly wired when hostname is set.
@vuepress/plugin-sitemapsitemaptrueOnly wired when hostname is set.

The Markdown plugins — Shiki, Markdown Ext, Markdown Raw, Markdown Hint, Markdown Tab and Links Check — are grouped under markdownPlugins instead, apart from the plugins above.

Search is not bundled. The navbar renders a SearchBox placeholder, which a search plugin fills: SlimSearch for a local index or DocSearch for Algolia. See Search.

Configuring plugins

A themePlugins entry accepts:

  • true (or leaving it out) — the theme enables the plugin with its own defaults.
  • false — the plugin is not wired at all, so neither its feature nor its client assets are loaded.
  • an object — the plugin is enabled, the object is merged over the defaults the theme passes.
import { defaultTheme } from '@vuepress/theme-default'
import { defineUserConfig } from 'vuepress'

export default defineUserConfig({
  theme: defaultTheme({
    themePlugins: {
      copyCode: { showInMobile: true },
      mediumZoom: { selector: '.vp-doc img' },
      icon: false,
    },
  }),
})

Some plugins are enabled by the theme options themselves rather than by themePlugins entries:

  • git receives updatedTime and contributors from lastUpdated and contributors. When every locale disables the contributors, the git plugin does not collect them.
  • markdownPlugins.hint receives the hint container labels from tip, warning, danger, important and note.
  • seo and sitemap require hostname.
  • shiki, activeHeaderLinks and copyCode scope their features to the classes the theme renders, so overriding those options may break the integration they rely on.

Tips

Disabling a plugin does not remove the markup the theme renders for it. For example, icon: false only means no icon is resolved, so an icon name stays as text.

themePlugins

themePlugins.copyCodeCopyCodePluginOptions | boolean
Defaulttrue

Wires Copy Code. The theme scopes it to the code blocks inside the page content with selector: '[vp-content] div[class*="language-"] pre'.

The object is merged over that selector, so it configures the behavior only:

themePlugins: {
  copyCode: {
    // copy the inline code on double click
    inline: true,
    // show the hint for 3000ms
    duration: 3000,
    showInMobile: true,
  },
}
themePlugins.gitGitPluginOptions | boolean
Defaulttrue

Wires Git. The theme disables the created time and the changelog, and enables the updated time and the contributors according to the theme options.

The object configures the rest:

themePlugins: {
  git: {
    // show the avatar of the contributors
    contributors: { avatar: true },
    // collect the changelog, which the theme does not render by default
    changelog: { repoUrl: 'https://github.com/vuepress/ecosystem' },
  },
}
themePlugins.activeHeaderLinksboolean
Defaulttrue

Wires Active Header Links with headerLinkSelector: '.outline-link', so the URL hash follows the outline while scrolling. Only a boolean: the selector is fixed by the theme because it is tied to the outline markup.

themePlugins.backToTopBackToTopPluginOptions | boolean
Defaulttrue

Wires Back To Top. The label of the button comes from the locales of the plugin.

themePlugins: {
  // show the button after 200px of scrolling, with a progress bar
  backToTop: { threshold: 200, progress: true },
}
themePlugins.iconIconPluginOptions | boolean
Defaulttrue

Wires Icon with assets: 'iconify', i.e. the iconify web component resolved at runtime from the iconify CDN, which is what the navbar, sidebar and feature icons use.

The theme renders the icons through the VPIcon component, so the component option of the plugin is reserved by the theme and cannot be changed.

themePlugins: {
  icon: {
    // bundle the icon sets instead of loading them from the CDN
    offline: true,
    // resolve `icon: 'mdi:github'` as `icon: 'github'`
    prefix: 'mdi:',
  },
}
themePlugins.mediumZoomMediumZoomPluginOptions | boolean
Defaulttrue

Wires Medium Zoom.

themePlugins: {
  mediumZoom: { selector: '.vp-doc img' },
}
themePlugins.nprogressboolean
Defaulttrue

Wires NProgress, the progress bar shown on navigation. The plugin takes no options, so only a boolean is accepted. The bar style is themed by the theme CSS.

themePlugins.seoPartial<SeoPluginOptions> | boolean
Defaulttrue

Wires SEO when hostname is configured. The hostname is passed by the theme and the object adds the rest:

defaultTheme({
  hostname: 'https://example.com',
  themePlugins: {
    seo: {
      author: { name: 'VuePress' },
      autoDescription: true,
    },
  },
})
themePlugins.sitemapPartial<SitemapPluginOptions> | boolean
Defaulttrue

Wires Sitemap when hostname is configured.

defaultTheme({
  hostname: 'https://example.com',
  themePlugins: {
    sitemap: { changefreq: 'weekly', excludePaths: ['/404.html'] },
  },
})

markdownPlugins

markdownPluginsMarkdownPluginsOptions

The options of the Markdown plugins wired by the theme. A key accepts true (or leaving it out) to enable the plugin with its defaults, false to skip the plugin, and an object that is merged over the defaults.

import { defaultTheme } from '@vuepress/theme-default'
import { defineUserConfig } from 'vuepress'

export default defineUserConfig({
  theme: defaultTheme({
    markdownPlugins: {
      shiki: { themes: { light: 'vitesse-light', dark: 'vitesse-dark' } },
      hint: { alert: true },
    },
  }),
})
markdownPlugins.shikiShikiPluginOptions | boolean
Defaulttrue

Wires Shiki with the github-light and github-dark themes, which are consumed by the theme CSS as a light and a dark theme at the same time.

Pass a themes object to replace them:

markdownPlugins: {
  shiki: {
    themes: { light: 'vitesse-light', dark: 'vitesse-dark' },
  },
}

markdownPlugins.shiki: false leaves the code blocks unhighlighted. Pair it with @vuepress/plugin-prismjs if Prism is needed instead.

markdownPlugins.linksCheckLinksCheckPluginOptions | boolean
Defaulttrue

Wires Links Check with the plugin defaults. The object is the plugin options:

markdownPlugins: {
  linksCheck: {
    // do not check the anchor links in development
    dev: false,
    // fail the build on a dead link
    build: 'error',
  },
}
markdownPlugins.extMarkdownExtPluginOptions | boolean
Defaulttrue

Wires Markdown Ext with the v-pre container only, i.e. { vPre: true }.

The other Markdown extensions of the plugin are opt-in. gfm: true enables the GFM support — footnotes, task lists, soft line breaks and linkified URLs:

markdownPlugins: {
  ext: { gfm: true },
}
markdownPlugins.rawMarkdownRawPluginOptions | boolean
Defaulttrue

Wires Markdown Raw with isolateStyles: true, so the styles of the theme are isolated from the raw content.

markdownPlugins.hintMarkdownHintPluginOptions | boolean
Defaulttrue

Wires Markdown Hint with hint: true and alert: true, plus the localized labels of the theme options.

markdownPlugins: {
  // disable the GFM alerts, keep the containers
  hint: { alert: false },
}
markdownPlugins.tabMarkdownTabPluginOptions | boolean
Defaulttrue

Wires Markdown Tab with codeTabs: true. Code tabs work out of the box; the generic ::: tabs group is opt-in:

markdownPlugins: {
  tab: { tabs: true },
}

The theme does not ship a search implementation. The navbar renders a SearchBox placeholder wherever a search plugin registers one, and the outline, the sidebar and the keyboard shortcut stay owned by the plugin.

import { slimsearchPlugin } from '@vuepress/plugin-slimsearch'

export default defineUserConfig({
  theme: defaultTheme({}),
  plugins: [slimsearchPlugin()],
})

The available search plugins are SlimSearch, DocSearch, Orama, MeiliSearch, FlexSearch and the legacy Search.

MIT Licensed