Plugin

With the help of Plugin API, VuePress plugin can provide different features for you.

Community Plugin

Community users have created lots of plugins and published them to NPMPlugin - 图1open in new window. VuePress team also maintains some official plugins under the @vuepressPlugin - 图2open in new window scope. You should check the plugin’s own documentation for detailed guide.

In general, you need to specify the name of the plugin to use in plugins option:

  1. module.exports = {
  2. plugins: [
  3. 'foo',
  4. ['bar', { /* options */ }]
  5. ],
  6. }

You can use either plugin name or its shorthand:

Plugin NameShorthand
vuepress-plugin-foofoo
@org/vuepress-plugin-bar@org/bar
@vuepress/plugin-foobar@vuepress/foobar

TIP

Most plugins can only be used once. If the same plugin is used multiple times, only the last one will take effect.

However, some plugins can be used multiple times (e.g. @vuepress/plugin-container), and you should check the documentation of the plugin itself for detailed guide.

Local Plugin

If you want to use your own plugin but don’t want to publish it, you can create a local plugin.

It is recommended to use the Config File directly as a plugin, because almost all of the Plugin APIs are available, which would be more convenient in most cases.

But if you have too many things to do in your config file, it’s better to extract them into separate plugins, and use them by setting the absolute path to them or requiring them:

  1. module.exports = {
  2. plugins: [
  3. path.resolve(__dirname, './path/to/your-plugin.js'),
  4. require('./another-plugin'),
  5. ],
  6. }

You can refer to Advanced > Writing a Plugin for how to write your own plugin.