Skip to content

How to understand a Docusaurus codebase

Docusaurus turns Markdown and MDX into a documentation site with React. Most of a Docusaurus repository is content; the code lives in the config, sidebars, custom pages and any theme components that were swizzled (copied out of the theme to customise).

How to tell it's Docusaurus

  • docusaurus.config.js (or .ts) and @docusaurus/core in package.json
  • docs/, blog/ and sidebars.js
  • A src/theme/ folder with overridden components

Where things usually live

docusaurus.config.js
Site URL, navbar, footer, presets, plugins, i18n.
sidebars.js
Sidebar structure for docs, often auto-generated from folders.
docs/
Documentation pages in Markdown or MDX.
src/pages/
Custom React pages such as the home page.
src/theme/
Swizzled theme components that replace defaults.
src/components/
Components used inside MDX.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. docusaurus.config.js
  2. sidebars.js, to understand docs navigation
  3. src/theme/, for anything that behaves differently from stock Docusaurus

How a request moves through the code

  1. 1Plugins load docs, blog posts and pages at build time.
  2. 2Each Markdown file becomes a route, wrapped in theme layout components.
  3. 3Swizzled components in src/theme/ replace the defaults with the same name.
  4. 4The site builds to static HTML and hydrates as a React app.

Questions to ask about the repository

  • Which theme components have been swizzled, and what do they change?
  • How is the docs sidebar built?
  • Which plugins are configured, and what does each add?

What trips people up

  • Swizzled components stop receiving upstream fixes; they are a common source of upgrade breakage.
  • MDX is stricter than Markdown, so stray < or { characters can break a build.