Skip to main content
Docusaurus

Search documentation

Type to search this documentation.

On this pageOverview

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

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

Accepted fields:

mdx-code-block
<APITable>
Name Type Default Description
path string 'src/pages' Path to data on filesystem relative to site dir. Components in this directory will be automatically converted to pages.
editUrl string | [EditUrlFn](#EditUrlFn) undefined Only for Markdown pages. Base URL to edit your site. The final URL is computed by editUrl + relativePostPath. Using a function allows more nuanced control for each file. Omitting this variable entirely will disable edit links.
editLocalizedFiles boolean false Only for Markdown pages. The edit URL will target the localized file, instead of the original unlocalized file. Ignored when editUrl is a function.
routeBasePath string '/' URL route for the pages section of your site. DO NOT include a trailing slash.
include string[] ['**/*.{js,jsx,ts,tsx,md,mdx}'] Matching files will be included and processed.
exclude string[] See example configuration No route will be created for matching files.
mdxPageComponent string '@theme/MDXPage' Component used by each MDX page.
remarkPlugins any[] [] Remark plugins passed to MDX.
rehypePlugins any[] [] Rehype plugins passed to MDX.
recmaPlugins any[] [] Recma plugins passed to MDX.
beforeDefaultRemarkPlugins any[] [] Custom Remark plugins passed to MDX before the default Docusaurus Remark plugins.
beforeDefaultRehypePlugins any[] [] Custom Rehype plugins passed to MDX before the default Docusaurus Rehype plugins.
showLastUpdateAuthor boolean false Only for Markdown pages. Whether to display the author who last updated the page.
showLastUpdateTime boolean false Only for Markdown pages. Whether to display the last date the page post was updated. This requires access to git history during the build, so will not work correctly with shallow clones (a common default for CI systems). With GitHub actions/checkout, use fetch-depth: 0. When deploying to Vercel, set the environment variable VERCEL_DEEP_CLONE=true.
mdx-code-block
</APITable>
TypeScript
type EditUrlFunction = (params: {
  blogDirPath: string;
  blogPath: string;
  permalink: string;
  locale: string;
}) => string | undefined;

You can configure this plugin through preset options or plugin options.

config-tabs
// Preset Options: pages
// Plugin Options: @docusaurus/plugin-content-pages

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('./my-remark-plugin')],
  rehypePlugins: [],
  beforeDefaultRemarkPlugins: [],
  beforeDefaultRehypePlugins: [],
};

Markdown pages can use the following Markdown front matter metadata fields, enclosed by a line --- on either side.

Accepted fields:

mdx-code-block
<APITable>
Name Type Default Description
title string Markdown title The blog post title.
description string The first line of Markdown content The description of your page, which will become the <meta name="description" content="..."/> and <meta property="og:description" content="..."/> in <head>, used by search engines.
keywords string[] undefined Keywords meta tag, which will become the <meta name="keywords" content="keyword1,keyword2,..."/> in <head>, used by search engines.
image string undefined Cover or thumbnail image that will be used as the <meta property="og:image" content="..."/> in the <head>, enhancing link previews on social media and messaging platforms.
slug string File path Allows to customize the page URL (/<routeBasePath>/<slug>). Supports multiple patterns: slug: my-page, slug: /my/page, slug: /.
wrapperClassName string Class name to be added to the wrapper element to allow targeting specific page content.
hide_table_of_contents boolean false Whether to hide the table of contents to the right.
draft boolean false Draft pages will only be available during development.
unlisted boolean false Unlisted pages will be available in both development and production. They will be "hidden" in production, not indexed, excluded from sitemaps, and can only be accessed by users having a direct link.
mdx-code-block
</APITable>

Example:

Markdown
---
title: Markdown Page
description: Markdown page SEO description
wrapperClassName: markdown-page
hide_table_of_contents: false
draft: true
slug: /markdown-page
---

Markdown page content

Read the i18n introduction first.

  • 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
Bash
website/i18n/[locale]/docusaurus-plugin-content-pages
│
│ # translations for website/src/pages
├── first-markdown-page.md
└── second-markdown-page.md
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu