The usual Docusaurus initialization with npx create-docusaurus@latest my-website classic
comes with a lot of dummy content that I must remove.
That is probably okay for most people who will start a documentation once every few months.
But I hope to place a copy of Docusaurus in every project I have, by default. And I don't want to go through the desolate process of de-dummifying a new doc everytime. I plan to use this blank template instead of the official starter template.
Get started quick with:
npx create-docusaurus@latest -g copy doc-for-x https://github.com/niravcodes/docusaurus-blank-starter
-
Simplified or removed most introductory artefact, removed the Blog feature, and simplified the homepage
-
Preinstalled Mermaid for diagramming and Katex for Math notation
-
The favicon, and all other images are now simple and non-dinosaur-including (nothing against dinosaurs in general, but cute green dinosaurs don't say "cool").
-
a
simpleConfig
object indocusaurus.config.ts
centralizes most things you'd want to change in a new doc site without having to parse the entire configconst simpleConfig = { title: "Documentation for X", tagline: "This is the documentation for X.", ghUser: "niravcodes", ghRepo: "", url: "https://your-docusaurus-site.example.com", baseUrl: "/", };
-
Default color changed from green to blue
-
Removed footer
-
Initialize the doc
npx create-docusaurus@latest -g copy doc-for-x https://github.com/niravcodes/docusaurus-blank-starter # or git clone https://github.com/niravcodes/docusaurus-blank-starter cd docusaurus-blank-starter npm install
I recommend that you store the docs in the same directory and repo where your code also lives (Docs as Code).
- Edit the
simpleConfig
object indocusaurus.config.ts
config file to reflect your project
-
Follow low effort installation first
-
Edit the images in
static/img/
to reflect your brand -
Edit the colors in
src/css/custom.css
to reflect your brand. A handy CSS generator and tester is available in the Docusaurus Docs -
If you don't need Mermaid and Katex, remove them from
package.json
anddocusaurus.config.ts
. -
If you need a homepage that is not the docs index:
a. Remove the line
routeBasePath: "/",
from thedocs
preset config indocusaurus.config.ts
.b. Rename
src/pages/somepage.tsx
tosrc/pages/index.tsx
and write your homepage in React.
If you are documenting a TypeScript project, you can use Typedoc to have code-reference style docs generated from the code and the comments, on top of all the hand-written text.
To set that up, use docusaurus-plugin-typedoc like so:
npm install typedoc typedoc-plugin-markdown docusaurus-plugin-typedoc --save-dev
module.exports = {
// Add option types
// ...
plugins: [
[
"docusaurus-plugin-typedoc",
// Options
{
entryPoints: ["../src/index.ts"],
tsconfig: "../tsconfig.json",
},
],
// ...
],
};