Docusaurus
Overview
Docusaurus (by Meta / the facebook org) is a static site generator that builds documentation websites and blogs as a React single-page app rendered to static HTML. It centers on MDX content, a docs/ + blog/ structure, versioning, and built-in i18n and search integrations. Read this when scaffolding a Docusaurus site, editing docusaurus.config.js or sidebars.js, authoring MDX, or configuring versioning and internationalization.
Official sources
- Docs: https://docusaurus.io/docs
- Repo: https://github.com/facebook/docusaurus
- Install: https://docusaurus.io/docs/installation
Install / setup
npx create-docusaurus@latest my-website classic
cd my-website
npm run start
Commands from the official installation docs: https://docusaurus.io/docs/installation
Core concepts
- Classic preset —
@docusaurus/preset-classicbundles the docs, blog, pages, and theme/CSS; configured underpresetsin the config. docusaurus.config.js— central site config (title, URL, presets, plugins,themeConfigfor navbar/footer).- MDX content — docs and blog posts are MDX, mixing Markdown with imported React components.
- Sidebars —
sidebars.jsdefines the docs navigation tree (autogenerated from folders or hand-authored). - Docs versioning —
npm run docusaurus docs:version <v>snapshots docs so multiple versions ship side by side. - i18n — built-in localization writes translations under
i18n/<locale>/and builds per-locale sites. - Pages & swizzling — standalone React/MDX pages live in
src/pages/; "swizzling" overrides theme components for customization.
Best practices
- Use
create-docusaurus@latest ... classicto scaffold so you start from the supported preset (https://docusaurus.io/docs/installation). - Pass
--typescriptto scaffold a typed config and components when you want TS (https://docusaurus.io/docs/installation). - Cut new doc versions with
docs:versionrather than copying folders, to keep the version dropdown consistent (https://docusaurus.io/docs/versioning). - Prefer
--ejectswizzling sparingly and favor--wrap, since wrapping survives upgrades better (https://docusaurus.io/docs/swizzling).
Common pitfalls
- Broken internal links fail
npm run buildby default → fix the link or adjustonBrokenLinksin the config. - Heavy use of ejected (swizzled) theme components → upgrades break; prefer wrapping or theme config where possible.
Examples
// docusaurus.config.js (excerpt)
export default {
title: 'My Docs',
url: 'https://example.com',
baseUrl: '/',
presets: [
['classic', { docs: { sidebarPath: './sidebars.js' }, blog: {} }],
],
};
Further reading
- https://docusaurus.io/docs/category/guides — feature guides (docs, blog, versioning, i18n)
- https://docusaurus.io/docs/api/docusaurus-config — full config API reference
Related skills
- ../astro — content framework with islands and partial hydration
- ../nextjs — React meta-framework for full-stack apps
- ../eleventy — JavaScript SSG with flexible template languages