Skip to main content
Version: 3.10.2

📦 plugin-content-blog

Provides the Blog feature and is the default blog plugin for Docusaurus.

some features production only

The feed feature works by extracting the build output, and is only active in production.

Installation

npm install --save @docusaurus/plugin-content-blog
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'blog'Path to the blog content directory on the file system, relative to site dir.
editUrlstring | EditUrlFnundefinedBase 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.
editLocalizedFilesbooleanfalseThe edit URL will target the localized file, instead of the original unlocalized file. Ignored when editUrl is a function.
blogTitlestring'Blog'Blog page title for better SEO.
blogDescriptionstring'Blog'Blog page meta description for better SEO.
blogSidebarCountnumber | 'ALL'5Number of blog post elements to show in the blog sidebar. 'ALL' to show all blog posts; 0 to disable.
blogSidebarTitlestring'Recent posts'Title of the blog sidebar.
routeBasePathstring'blog'URL route for the blog section of your site. DO NOT include a trailing slash. Use / to put the blog at root path.
tagsBasePathstring'tags'URL route for the tags section of your blog. Will be appended to routeBasePath.
pageBasePathstring'page'URL route for the pages section of your blog. Will be appended to routeBasePath.
archiveBasePathstring | null'archive'URL route for the archive section of your blog. Will be appended to routeBasePath. DO NOT include a trailing slash. Use null to disable generation of archive.
authorsBasePathstring'authors'URL route for the authors pages of your blog. Will be appended to path.
includestring[]['**/*.{md,mdx}']Array of glob patterns matching Markdown files to be built, relative to the content path.
excludestring[]See example configurationArray of glob patterns matching Markdown files to be excluded. Serves as refinement based on the include option.
postsPerPagenumber | 'ALL'10Number of posts to show per page in the listing page. Use 'ALL' to display all posts on one listing page.
blogListComponentstring'@theme/BlogListPage'Root component of the blog listing page.
blogPostComponentstring'@theme/BlogPostPage'Root component of each blog post page.
blogTagsListComponentstring'@theme/BlogTagsListPage'Root component of the tags list page.
blogTagsPostsComponentstring'@theme/BlogTagsPostsPage'Root component of the "posts containing tag" page.
blogArchiveComponentstring'@theme/BlogArchivePage'Root component of the blog archive page.
blogAuthorsPostsComponentstring'@theme/Blog/Pages/BlogAuthorsPostsPage'Root component of the blog author page.
blogAuthorsListComponentstring'@theme/Blog/Pages/BlogAuthorsListPage'Root component of the blog authors page index.
remarkPluginsany[][]Remark plugins passed to MDX.
rehypePluginsany[][]Rehype plugins passed to MDX.
recmaPluginsany[][]Recma 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.
truncateMarkerRegExp/<!--\s*truncate\s*-->/ | \{\/\*\s*truncate\s*\*\/\}/Truncate marker marking where the summary ends.
showReadingTimebooleantrueShow estimated reading time for the blog post.
readingTimeReadingTimeFnThe default reading timeA callback to customize the reading time number displayed.
authorsMapPathstring'authors.yml'Path to the authors map file, relative to the blog content directory.
feedOptionsSee below{type: ['rss', 'atom']}Blog feed.
feedOptions.typeFeedType | FeedType[] | 'all' | nullRequiredType of feed to be generated. Use null to disable generation.
feedOptions.createFeedItemsCreateFeedItemsFn | undefinedundefinedAn optional function which can be used to transform and / or filter the items in the feed.
feedOptions.limitnumber | null | false20Limits the feed to the specified number of posts, false or null for all entries. Defaults to 20.
feedOptions.titlestringsiteConfig.titleTitle of the feed.
feedOptions.descriptionstring`${siteConfig.title} Blog`Description of the feed.
feedOptions.copyrightstringundefinedCopyright message.
feedOptions.xsltboolean | FeedXSLTOptionsundefinedPermits to style the blog XML feeds with XSLT so that browsers render them nicely.
feedOptions.languagestring (See documentation for possible values)undefinedLanguage metadata of the feed.
sortPosts'descending' | 'ascending''descending'Governs the direction of blog post sorting.
processBlogPostsProcessBlogPostsFnundefinedAn optional function which can be used to transform blog posts (filter, modify, delete, etc...).
showLastUpdateAuthorbooleanfalseWhether to display the author who last updated the blog post.
showLastUpdateTimebooleanfalseWhether to display the last date the blog 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.
tagsstring | false | null | undefinedtags.ymlPath to the YAML tags file listing pre-defined tags. Relative to the blog content directory.
onInlineTags'ignore' | 'log' | 'warn' | 'throw'warnThe plugin behavior when blog posts contain inline tags (not appearing in the list of pre-defined tags, usually tags.yml).
onUntruncatedBlogPosts'ignore' | 'log' | 'warn' | 'throw'warnThe plugin behavior when blog posts do not contain a truncate marker.

Types

EditUrlFn

type EditUrlFunction = (params: {
blogDirPath: string;
blogPath: string;
permalink: string;
locale: string;
}) => string | undefined;

ReadingTimeFn

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;

FeedType

type FeedType = 'rss' | 'atom' | 'json';

FeedXSLTOptions

Permits to style the blog XML feeds so that browsers render them nicely with XSLT.

  • Use true to let the blog use its built-in .xsl and .css files to style the blog feed
  • Use a falsy value (undefined | null | false) to disable the feature
  • Use a string to provide a file path to a custom .xsl file relative to the blog content folder. By convention, you must provide a .css file with the exact same name.
type FeedXSLTOptions =
| boolean
| undefined
| null
| {
rss?: string | boolean | null | undefined;
atom?: string | boolean | null | undefined;
};

CreateFeedItemsFn

type CreateFeedItemsFn = (params: {
blogPosts: BlogPost[];
siteConfig: DocusaurusConfig;
outDir: string;
defaultCreateFeedItemsFn: CreateFeedItemsFn;
}) => Promise<BlogFeedItem[]>;

ProcessBlogPostsFn