English
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
| Plugin | themePlugins key | Default | Notes |
|---|---|---|---|
@vuepress/plugin-theme-data | — | enabled | Always enabled. |
@vuepress/plugin-copy-code | copyCode | true | Scoped to the code blocks in the page content. |
@vuepress/plugin-git | git | true | Collects the last updated time and the contributors. |
@vuepress/plugin-active-header-links | activeHeaderLinks | true | Keeps the URL hash in sync with the outline. |
@vuepress/plugin-back-to-top | backToTop | true | The back to top button. |
@vuepress/plugin-icon | icon | true | Iconify assets, loaded at runtime. |
@vuepress/plugin-medium-zoom | mediumZoom | true | Image zoom on the document images. |
@vuepress/plugin-nprogress | nprogress | true | The progress bar on navigation. |
@vuepress/plugin-seo | seo | true | Only wired when hostname is set. |
@vuepress/plugin-sitemap | sitemap | true | Only 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:
gitreceivesupdatedTimeandcontributorsfromlastUpdatedandcontributors. When every locale disables the contributors, the git plugin does not collect them.markdownPlugins.hintreceives the hint container labels fromtip,warning,danger,importantandnote.seoandsitemaprequirehostname.shiki,activeHeaderLinksandcopyCodescope 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.copyCode
CopyCodePluginOptions | booleanDefault
trueWires 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.git
GitPluginOptions | booleanDefault
trueWires 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.activeHeaderLinks
booleanDefault
trueWires 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.backToTop
BackToTopPluginOptions | booleanDefault
trueWires 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.icon
IconPluginOptions | booleanDefault
trueWires 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.mediumZoom
MediumZoomPluginOptions | booleanDefault
trueWires Medium Zoom.
themePlugins: {
mediumZoom: { selector: '.vp-doc img' },
}themePlugins.nprogress
booleanDefault
trueWires 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.seo
Partial<SeoPluginOptions> | booleanDefault
truemarkdownPlugins
markdownPlugins
MarkdownPluginsOptionsThe 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.shiki
ShikiPluginOptions | booleanDefault
trueWires 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.linksCheck
LinksCheckPluginOptions | booleanDefault
trueWires 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.ext
MarkdownExtPluginOptions | booleanDefault
trueWires 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.raw
MarkdownRawPluginOptions | booleanDefault
trueWires Markdown Raw with isolateStyles: true, so the styles of the theme are isolated from the raw content.
markdownPlugins.hint
MarkdownHintPluginOptions | booleanDefault
trueWires 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.tab
MarkdownTabPluginOptions | booleanDefault
trueWires Markdown Tab with codeTabs: true. Code tabs work out of the box; the generic ::: tabs group is opt-in:
markdownPlugins: {
tab: { tabs: true },
}Search
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.
