Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/facebook/docusaurus/llms.txt

Use this file to discover all available pages before exploring further.

@docusaurus/plugin-content-blog provides the full-featured blogging system built into Docusaurus. It reads Markdown and MDX post files, organizes them by date, generates tag pages, author pages, and produces RSS, Atom, and JSON feeds. The plugin is included in @docusaurus/preset-classic and requires no separate installation when using that preset.
The feed feature (RSS/Atom/JSON) operates on the build output and is only active in production. It will not generate feeds during docusaurus start.

Installation

npm2yarn
npm install --save @docusaurus/plugin-content-blog
If you use @docusaurus/preset-classic, configure this plugin through the blog preset key instead of adding it to the plugins array.

Configuration options

Content and routing

OptionTypeDefaultDescription
pathstring'blog'Path to the blog content directory on the filesystem, relative to the site directory.
routeBasePathstring'blog'URL route for the blog section. Do not include a trailing slash. Use / to serve the blog from the site root.
tagsBasePathstring'tags'URL route for the tags section, appended to routeBasePath.
pageBasePathstring'page'URL route for paginated list pages, appended to routeBasePath.
archiveBasePathstring | null'archive'URL route for the archive page, appended to routeBasePath. Set null to disable the archive.
authorsBasePathstring'authors'URL route for author pages, appended to routeBasePath.
includestring[]['**/*.{md,mdx}']Glob patterns for blog post files to include, relative to the content path.
excludestring[]see exampleGlob patterns for files to exclude. Refines the include list.

Display options

OptionTypeDefaultDescription
blogTitlestring'Blog'Page title for the blog listing page, used in SEO metadata.
blogDescriptionstring'Blog'Meta description for the blog listing page.
blogSidebarCountnumber | 'ALL'5Number of recent posts shown in the blog sidebar. Use 'ALL' to show all posts, 0 to disable the sidebar.
blogSidebarTitlestring'Recent posts'Title text shown above the blog sidebar list.
postsPerPagenumber | 'ALL'10Number of posts shown per listing page. Use 'ALL' to display all posts on a single page.
showReadingTimebooleantrueDisplay an estimated reading time on each blog post.
readingTimeReadingTimeFnbuilt-inCustom function to calculate or format the reading time number.
truncateMarkerRegExp/<!--\s*truncate\s*-->/Marker used to split blog post content into a summary and full content.
sortPosts'descending' | 'ascending''descending'Sort order for blog posts by date.
OptionTypeDefaultDescription
editUrlstring | EditUrlFnundefinedBase URL for “Edit this page” links. A function receives {blogDirPath, blogPath, permalink, locale}. Omit to disable edit links.
editLocalizedFilesbooleanfalseWhen true, edit links target the localized file. Ignored when editUrl is a function.

Last update metadata

OptionTypeDefaultDescription
showLastUpdateAuthorbooleanfalseDisplay the author of the last git commit for each post.
showLastUpdateTimebooleanfalseDisplay the date of the last git commit for each post. Requires full git history.

Authors and tags

OptionTypeDefaultDescription
authorsMapPathstring'authors.yml'Path to the global authors YAML file, relative to the blog content directory.
tagsstring | false | null'tags.yml'Path to a YAML file defining pre-defined tags, relative to the blog content directory.
onInlineTags'ignore' | 'log' | 'warn' | 'throw''warn'Behavior when posts use tags not declared in the pre-defined tags file.
onUntruncatedBlogPosts'ignore' | 'log' | 'warn' | 'throw''warn'Behavior when posts do not contain a truncate marker.

Feed options

OptionTypeDefaultDescription
feedOptions.typeFeedType | FeedType[] | 'all' | null['rss', 'atom']Feed format(s) to generate. Use null to disable feed generation.
feedOptions.titlestringsiteConfig.titleFeed title.
feedOptions.descriptionstring"${siteConfig.title} Blog"Feed description.
feedOptions.copyrightstringundefinedCopyright string appended to the feed.
feedOptions.languagestringundefinedBCP 47 language code for the feed.
feedOptions.limitnumber | null | false20Maximum number of posts included in the feed. Use null or false for no limit.
feedOptions.xsltboolean | FeedXSLTOptionsundefinedStyle XML feeds with XSLT so browsers render them attractively.
feedOptions.createFeedItemsCreateFeedItemsFnundefinedCustom function to transform or filter feed items before they are written.

Processing and components

OptionTypeDefaultDescription
processBlogPostsProcessBlogPostsFnundefinedOptional function to filter, transform, or delete posts after they are loaded.
blogListComponentstring'@theme/BlogListPage'Root component of the blog listing page.
blogPostComponentstring'@theme/BlogPostPage'Root component of each individual blog post page.
blogTagsListComponentstring'@theme/BlogTagsListPage'Root component of the tags list page.
blogTagsPostsComponentstring'@theme/BlogTagsPostsPage'Root component of the “posts with tag X” page.
blogArchiveComponentstring'@theme/BlogArchivePage'Root component of the blog archive page.
blogAuthorsPostsComponentstring'@theme/Blog/Pages/BlogAuthorsPostsPage'Root component of an individual author’s posts page.
blogAuthorsListComponentstring'@theme/Blog/Pages/BlogAuthorsListPage'Root component of the authors index page.
remarkPluginsany[][]Remark plugins passed to the MDX processor.
rehypePluginsany[][]Rehype plugins passed to the MDX processor.
recmaPluginsany[][]Recma plugins passed to the MDX processor.
beforeDefaultRemarkPluginsany[][]Remark plugins injected before Docusaurus’s built-in Remark plugins.
beforeDefaultRehypePluginsany[][]Rehype plugins injected before Docusaurus’s built-in Rehype plugins.

Type definitions

type FeedType = 'rss' | 'atom' | 'json';
type FeedXSLTOptions =
  | boolean
  | undefined
  | null
  | {
      rss?: string | boolean | null | undefined;
      atom?: string | boolean | null | undefined;
    };
Use true to apply the built-in .xsl and .css stylesheets. Pass a path string (relative to the blog content folder) to use a custom .xsl file — a matching .css file with the same base name must also be present.
type CreateFeedItemsFn = (params: {
  blogPosts: BlogPost[];
  siteConfig: DocusaurusConfig;
  outDir: string;
  defaultCreateFeedItemsFn: CreateFeedItemsFn;
}) => Promise<BlogFeedItem[]>;
type ReadingTimeOptions = {
  wordsPerMinute: number;
};

type ReadingTimeCalculator = (params: {
  content: string;
  locale: string;
  frontMatter?: BlogPostFrontMatter & Record<string, unknown>;
  options?: ReadingTimeOptions;
}) => number;

type ReadingTimeFn = (params: {
  content: string;
  locale: string;
  frontMatter: BlogPostFrontMatter & Record<string, unknown>;
  defaultReadingTime: ReadingTimeCalculator;
}) => number | undefined;
type ProcessBlogPostsFn = (params: {
  blogPosts: BlogPost[];
}) => Promise<void | BlogPost[]>;
type EditUrlFunction = (params: {
  blogDirPath: string;
  blogPath: string;
  permalink: string;
  locale: string;
}) => string | undefined;

Example configuration

Markdown front matter

Individual blog post files can use the following front matter fields.
FieldTypeDefaultDescription
titlestringMarkdown headingBlog post display title.
title_metastringtitleOverride the SEO <title> and og:title independently from the displayed title.
authorsAuthorsundefinedPost author(s). Accepts an author key, an inline author object, or an array of both.
datestringfilename or file creation timePost date. Can be extracted from the filename (e.g. 2024-01-15-my-post.mdx) or set explicitly.
tagsTag[]undefinedTags to apply. Strings may reference keys from tags.yml.
draftbooleanfalseDraft posts are only available in development.
unlistedbooleanfalseUnlisted posts are hidden from navigation and sitemaps but reachable via direct URL.
slugstringfile pathCustom URL path for the post.
descriptionstringfirst line of content<meta name="description"> and OpenGraph description.
keywordsstring[]undefined<meta name="keywords"> content.
imagestringundefinedOpenGraph og:image for social link previews.
sidebar_labelstringtitleCustom label for this post in the blog sidebar.
hide_table_of_contentsbooleanfalseHide the table of contents panel.
toc_min_heading_levelnumber2Minimum heading level in the TOC.
toc_max_heading_levelnumber3Maximum heading level in the TOC.
last_updateFrontMatterLastUpdateundefinedManually override the last update author or date.

Authors type

type AuthorKey = string;

type AuthorSocials = Record<string, string>;

type Author = {
  key?: AuthorKey;
  name: string;
  title?: string;
  url?: string;
  image_url?: string;
  socials?: AuthorSocials;
};

type Authors = AuthorKey | Author | (AuthorKey | Author)[];

Authors file (authors.yml)

Define global reusable authors in a YAML file at the root of your blog content directory. The path is controlled by the authorsMapPath option.
blog/authors.yml
slorber:
  name: Sébastien Lorber
  title: Docusaurus maintainer
  url: https://sebastienlorber.com
  image_url: https://github.com/slorber.png
  page: true
  socials:
    github: slorber
    x: sebastienlorber

jmarcey:
  name: Joel Marcey
  title: Co-creator of Docusaurus 1
  url: https://github.com/JoelMarcey
  image_url: https://github.com/JoelMarcey.png
  page:
    permalink: '/authors/joel-marcey'
  socials:
    github: JoelMarcey
Reference an author in a post using their key:
blog/2024-01-15-hello.md
---
title: Hello World
authors: [slorber, jmarcey]
tags: [docusaurus, release]
---

Post content here.

i18n

Translated blog posts live under website/i18n/[locale]/docusaurus-plugin-content-blog/. For multi-instance setups, the folder name becomes docusaurus-plugin-content-blog-[pluginId].

Build docs developers (and LLMs) love