LinuxCommandLibrary

docusaurus

TLDR

Create a new Docusaurus site

$ npx create-docusaurus@latest [my-website] classic
copy
Start development server
$ npx docusaurus start
copy
Build for production
$ npx docusaurus build
copy
Serve built site locally
$ npx docusaurus serve
copy
Deploy to GitHub Pages
$ npx docusaurus deploy
copy
Clear build cache
$ npx docusaurus clear
copy
Generate new doc page
$ npx docusaurus docs:version [1.0]
copy

SYNOPSIS

npx docusaurus command [options]

DESCRIPTION

Docusaurus is a static site generator optimized for documentation websites. It uses React for the UI, Markdown/MDX for content, and provides features like versioning, i18n, and search out of the box.
Sites are configured via docusaurus.config.js, defining metadata, themes, plugins, and navigation. Content lives in docs/ for documentation and blog/ for blog posts.
The development server provides hot reloading. Production builds generate static HTML, CSS, and JavaScript that can be hosted anywhere. Built-in deployment support targets GitHub Pages.

PARAMETERS

start [--port n]

Start development server (default port 3000).
build [--out-dir path]
Build static site for production.
serve [--port n]
Serve built site locally.
deploy
Deploy to GitHub Pages.
clear
Clear generated files and caches.
swizzle theme component
Eject or wrap a theme component.
docs:version version
Create new documentation version.
write-translations
Extract translatable strings.
write-heading-ids
Add heading IDs to markdown files.
--locale locale
Specify locale for command.
--config path
Use custom config file.

PROJECT STRUCTURE

$ my-website/
├── docs/           # Documentation markdown
├── blog/           # Blog posts
├── src/
│   ├── components/ # React components
│   └── pages/      # Custom pages
├── static/         # Static assets
├── docusaurus.config.js
└── sidebars.js     # Sidebar configuration
copy

CAVEATS

Requires Node.js 18+. Large sites may have slow build times. Custom React components need familiarity with React. Swizzling (customizing) theme components may break on upgrades. Search requires additional setup (Algolia or local search plugin).

HISTORY

Docusaurus was created at Facebook (Meta) and open-sourced in 2017. It was designed to power documentation for Facebook's open-source projects. Version 2, a complete rewrite using React, was released in 2022. The project is maintained by Meta and a community of contributors.

SEE ALSO

gatsby(1), vitepress(1), mkdocs(1), hugo(1)

Copied to clipboard