Skip to main content
Version: 2.0.0-beta.6

πŸ“¦ plugin-content-pages

The default pages plugin for Docusaurus. The classic template ships with this plugin with default configurations. This plugin provides creating pages functionality.

Installation#

npm install --save @docusaurus/plugin-content-pages
tip

If you use the preset @docusaurus/preset-classic, you don't need to install this plugin as a dependency.

You can configure this plugin through the preset options.

Configuration#

Accepted fields:

NameTypeDefaultDescription
pathstring'src/pages'Path to data on filesystem relative to site dir. Components in this directory will be automatically converted to pages.
routeBasePathstring'/'URL route for the pages section of your site. DO NOT include a trailing slash.
includestring[]['**/*.{js,jsx,ts,tsx,md,mdx}']Matching files will be included and processed.
excludestring[]See example configurationNo route will be created for matching files.
mdxPageComponentstring'@theme/MDXPage'Component used by each MDX page.
remarkPlugins[]any[]Remark plugins passed to MDX.
rehypePlugins[]any[]Rehype plugins passed to MDX.
beforeDefaultRemarkPluginsany[][]Custom Remark plugins passed to MDX before the default Docusaurus Remark plugins.
beforeDefaultRehypePluginsany[][]Custom Rehype plugins passed to MDX before the default Docusaurus Rehype plugins.

Example configuration#

Here's an example configuration object.

You can provide it as preset options or plugin options.

tip

Most Docusaurus users configure this plugin through the preset options.

const config = {  path: 'src/pages',  routeBasePath: '',  include: ['**/*.{js,jsx,ts,tsx,md,mdx}'],  exclude: [    '**/_*.{js,jsx,ts,tsx,md,mdx}',    '**/_*/**',    '**/*.test.{js,jsx,ts,tsx}',    '**/__tests__/**',  ],  mdxPageComponent: '@theme/MDXPage',  remarkPlugins: [require('remark-math')],  rehypePlugins: [],  beforeDefaultRemarkPlugins: [],  beforeDefaultRehypePlugins: [],};

Preset options#

If you use a preset, configure this plugin through the preset options:

docusaurus.config.js
module.exports = {  presets: [    [      '@docusaurus/preset-classic',      {        pages: {          path: 'src/pages',          // ... configuration object here        },      },    ],  ],};

Plugin options#

If you are using a standalone plugin, provide options directly to the plugin:

docusaurus.config.js
module.exports = {  plugins: [    [      '@docusaurus/plugin-content-pages',      {        path: 'src/pages',        // ... configuration object here      },    ],  ],};

i18n#

Read the i18n introduction first.

Translation files location#

  • Base path: website/i18n/<locale>/docusaurus-plugin-content-pages
  • Multi-instance path: website/i18n/<locale>/docusaurus-plugin-content-pages-<pluginId>
  • JSON files: extracted with docusaurus write-translations
  • Markdown files: website/i18n/<locale>/docusaurus-plugin-content-pages

Example file-system structure#

website/i18n/<locale>/docusaurus-plugin-content-pagesβ”‚β”‚ # translations for website/src/pagesβ”œβ”€β”€ first-markdown-page.md└── second-markdown-page.md