📦 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
- Yarn
- pnpm
npm install --save @docusaurus/plugin-content-blog
yarn add @docusaurus/plugin-content-blog
pnpm add @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:
Name | Type | Default | Description |
---|---|---|---|
path | string | 'blog' | Path to the blog content directory on the file system, relative to site dir. |
editUrl | string | EditUrlFn | undefined | 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 | The edit URL will target the localized file, instead of the original unlocalized file. Ignored when editUrl is a function. |
blogTitle | string | 'Blog' | Blog page title for better SEO. |
blogDescription | string | 'Blog' | Blog page meta description for better SEO. |
blogSidebarCount | number | 'ALL' | 5 | Number of blog post elements to show in the blog sidebar. 'ALL' to show all blog posts; 0 to disable. |
blogSidebarTitle | string | 'Recent posts' | Title of the blog sidebar. |
routeBasePath | string | 'blog' | URL route for the blog section of your site. DO NOT include a trailing slash. Use / to put the blog at root path. |
tagsBasePath | string | 'tags' | URL route for the tags section of your blog. Will be appended to routeBasePath . DO NOT include a trailing slash. |
archiveBasePath | string | 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. |
include | string[] | ['**/*.{md,mdx}'] | Array of glob patterns matching Markdown files to be built, relative to the content path. |
exclude | string[] | See example configuration | Array of glob patterns matching Markdown files to be excluded. Serves as refinement based on the include option. |
postsPerPage | number | 'ALL' | 10 | Number of posts to show per page in the listing page. Use 'ALL' to display all posts on one listing page. |
blogListComponent | string | '@theme/BlogListPage' | Root component of the blog listing page. |
blogPostComponent | string | '@theme/BlogPostPage' | Root component of each blog post page. |
blogTagsListComponent | string | '@theme/BlogTagsListPage' | Root component of the tags list page. |
blogTagsPostsComponent | string | '@theme/BlogTagsPostsPage' | Root component of the "posts containing tag" page. |
blogArchiveComponent | string | '@theme/BlogArchivePage' | Root component of the blog archive page. |
remarkPlugins | any[] | [] | Remark plugins passed to MDX. |
rehypePlugins | any[] | [] | Rehype 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. |
truncateMarker | RegExp | /<!--\s*truncate\s*-->/ | \{\/\*\s*truncate\s*\*\/\}/ | Truncate marker marking where the summary ends. |
showReadingTime | boolean | true | Show estimated reading time for the blog post. |
readingTime | ReadingTimeFn | The default reading time | A callback to customize the reading time number displayed. |
authorsMapPath | string | 'authors.yml' | Path to the authors map file, relative to the blog content directory. |
feedOptions | See below | {type: ['rss', 'atom']} | Blog feed. |
feedOptions.type | FeedType | FeedType[] | 'all' | null | Required | Type of feed to be generated. Use null to disable generation. |
feedOptions.createFeedItems | CreateFeedItemsFn | undefined | undefined | An optional function which can be used to transform and / or filter the items in the feed. |
feedOptions.limit | number | null | false | 20 | Limits the feed to the specified number of posts, false or null for all entries. Defaults to 20 . |
feedOptions.title | string | siteConfig.title | Title of the feed. |
feedOptions.description | string | `${siteConfig.title} Blog` | Description of the feed. |
feedOptions.copyright | string | undefined | Copyright message. |
feedOptions.language | string (See documentation for possible values) | undefined | Language metadata of the feed. |
sortPosts | 'descending' | 'ascending' | 'descending' | Governs the direction of blog post sorting. |