禁用Blog功能
本文介绍如何禁用Blog功能。如果您只想让这个站点作为某个项目的项目文档站,或者只想使用Docusaurus写系列文章,不想在Docusaurus中写博客,可以禁用掉Blog功能。具体实现步骤如下:
在配种中删除Blog相关配置
需要对docusaurus.config.ts配置文件做以下修改
themeConfig
->navbar
中删除blog配置即可。删除后就不会在顶部导航中显示博客了。presets
中设置blog
为false
docusaurus.config.ts
export default {
presets: [
[
'classic',
{
docs: {
sidebarPath: './sidebars.ts',
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
remarkPlugins: [remarkMath],
rehypePlugins: [rehypeKatex],
},
blog: false,
theme: {
customCss: './src/css/custom.css',
},
} satisfies Preset.Options,
],
],
themeConfig: {
image: 'img/docusaurus-social-card.jpg',
logo: {
alt: 'My Site Logo',
src: 'img/logo.svg',
},
items: [
{
type: 'docSidebar',
sidebarId: 'tutorialSidebar',
position: 'left',
label: 'Tutorial',
},
//{to: '/blog', label: 'Blog', position: 'left'},
{
href: 'https://github.com/facebook/docusaurus',
label: 'GitHub',
position: 'right',
},
]
}
}
在sitemap中屏蔽blog页面
需要配置sitemap中的ignorePatterns
中增加/blog/**
export default {
presets: [
[
'classic',
{
sitemap: {
changefreq: EnumChangefreq.WEEKLY,
priority: 0.5,
ignorePatterns: ['/docs/tags/**', '/docusaurus-site/tags/**', '/tags/**', '/categories/**', '/blog/**'],
filename: 'sitemap.xml'
},
}
]
]
}