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/coreinpackage.jsondocs/,blog/andsidebars.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
docusaurus.config.jssidebars.js, to understand docs navigationsrc/theme/, for anything that behaves differently from stock Docusaurus
How a request moves through the code
- Plugins load docs, blog posts and pages at build time.
- Each Markdown file becomes a route, wrapped in theme layout components.
- Swizzled components in
src/theme/replace the defaults with the same name. - The 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.