Docusaurus Configuration
The following sections will describe how to modify the default Docusaurus layout to prepare for a documentation-focused GitHub Pages deployment.
Cleanup
This section is intended to remove unnecessary artifacts generated by create-docusaurus@latest
.
Delete the
src/pages
,src/components
, andblog
directories.Rename
docs/intro.md
todocs/index.md
then deletedocs/tutorial-basics
anddocs/tutorial-extras
. In theindex.md
front matter, setslug: /
.Delete the following from
static/img
:docusaurus.png
All
undraw
imagesdocusaurus-social-card.jpg
tipYou can generate your own social image card using a tool such as the Vercel OG Image Playground.
Configure
This section describes modifications to docusaurus.config.js
.
Throughout this section, only modified properties are specified.
Set the following to align the documentation with the metadata of your site repository:
const config = {
title: '<docs-title>',
tagline: '<docs-tagline>',
url: 'https://<gh-org-or-user>.github.io',
baseUrl: '/<gh-repo-name>',
organizationName: '<gh-org-or-user>',
projectName: '<gh-repo-name>',
deploymentBranch: '<gh-deploy-branch>',
trailingSlash: false,
}
Presets
Modify the docs
and blog
plugins to facilitate Docs-only mode:
presets: [
[
({
docs: {
routeBasePath: '/',
},
blog: false
})
]
]
Theme
Adjust themeConfig
to align with your docs metadata:
themeConfig:
({
image: 'img/<open-graph-card>',
navbar: {
title: '<docs-title>',
logo: {
alt: '<logo-alt>',
src: 'img/<logo-file>'
},
items: [
{
sidebarId: 'docsSidebar',
label: 'Docs'
},
{
href: '<repo-url>'
}
]
},
colorMode: {
respectPrefersColorScheme: true
}
})
To facilitate the new themeConfig.items.sidebarId
property, modify sidebars.js
:
const sidebars = {
docsSidebar: [{ type: 'autogenerated', dirname: '.' }]
}
Code Block Languages
Per the documentation, only a subset of commonly used languages are configured by default. Additional Prism-supported languages need to be added to defined:
themeConfig:
({
prism: {
additionalLanguages: ['csharp', 'powershell']
}
})