Loading...
Loading...
Docusaurus 3.x documentation framework — site configuration, docs/blog plugins, sidebars, versioning, MDX, swizzling, and deployment
npx skill4agent add agents-inc/skills web-meta-framework-docusaurusQuick Guide: Docusaurus 3.x is a React-powered static site generator for documentation. Configure everything in(ESM). Usedocusaurus.config.jsfor docs + blog + pages + sitemap in one preset. Sidebars can be fully autogenerated from filesystem structure using@docusaurus/preset-classicand front matter_category_.json. Customize theme components via swizzling (prefersidebar_positionover--wrap). MDX is the default content format — use front matter for metadata, admonitions for callouts, and import React components directly in--ejectfiles. Version docs with.mdx. Deploy thedocusaurus docs:versionoutput to any static host.build/
All code must follow project conventions in CLAUDE.md
docusaurus.config.js.ts@docusaurus/preset-classic--wrap--ejectsidebar_position_category_.jsondocusaurus.config.js_meta.json_category_.jsonastro.config.mjspreset-classicsidebar_positionslugtagscustom_edit_urldocusaurus buildexport default// docusaurus.config.js — minimal production setup
export default {
title: "My Docs",
tagline: "Documentation for My Project",
url: "https://docs.example.com",
baseUrl: "/",
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "throw",
favicon: "img/favicon.ico",
presets: [
[
"@docusaurus/preset-classic",
{
docs: {
sidebarPath: "./sidebars.js",
editUrl: "https://github.com/my-org/my-repo/edit/main/docs-site/",
showLastUpdateTime: true,
},
blog: { showReadingTime: true },
theme: { customCss: ["./src/css/custom.css"] },
},
],
],
themeConfig: {
navbar: {
title: "My Docs",
items: [
/* nav items */
],
},
footer: {
style: "dark",
links: [
/* footer columns */
],
},
docs: { sidebar: { hideable: true, autoCollapseCategories: true } },
},
};onBrokenLinks: 'throw'Full example: See examples/core.md for complete config with navbar, footer, and multi-instance docs setup.
// sidebars.js — autogenerated (recommended)
export default {
docs: [{ type: "autogenerated", dirName: "." }],
};_category_.json---
sidebar_position: 3
sidebar_label: Quick Start
---// docs/guides/_category_.json
{
"label": "Guides",
"position": 2,
"collapsible": true,
"collapsed": false,
"link": { "type": "generated-index", "title": "All Guides" }
}sidebar_position01-intro.mdFull example: See examples/core.md for manual sidebars, custom sidebar items generator, and multi-sidebar setups.
# List all swizzlable components
npx docusaurus swizzle --list
# Wrap a component (SAFE — preserves upstream updates)
npx docusaurus swizzle @docusaurus/theme-classic Footer -- --wrap
# Eject a component (DANGEROUS — you own the snapshot)
npx docusaurus swizzle @docusaurus/theme-classic Footer -- --eject// src/theme/Footer/index.js — wrapping example
import React from "react";
import Footer from "@theme-original/Footer";
export default function FooterWrapper(props) {
return (
<>
<Footer {...props} />
<div className="custom-banner">Custom content below footer</div>
</>
);
}@theme-original/@theme/@theme/FooterFull example: See examples/customization.md for swizzling safety levels, common swizzle targets, and CSS variable theming.
---
title: My Document
description: SEO description for this page
sidebar_position: 1
tags: [getting-started, tutorial]
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
:::tip[Pro Tip]
Admonitions support `note`, `tip`, `info`, `warning`, `danger` types.
The bracket syntax `:::tip[Custom Title]` sets the title.
:::
<Tabs>
<TabItem value="npm" label="npm" default>
```bash npm install my-package ```
</TabItem>
<TabItem value="yarn" label="yarn">
```bash yarn add my-package ```
</TabItem>
</Tabs>{<\{\<Full example: See examples/content.md for code block features, asset handling, and blog plugin configuration.
docs/current# Snapshot current docs as version 1.0.0
npx docusaurus docs:version 1.0.0versioned_docs/version-1.0.0/versioned_sidebars/version-1.0.0-sidebars.json// In preset-classic docs options
docs: {
lastVersion: 'current',
versions: {
current: { label: '2.0.0-beta', path: 'next', banner: 'unreleased' },
'1.0.0': { label: '1.0.0', path: '1.0.0', banner: 'none' },
},
onlyIncludeVersions: ['current', '1.0.0'],
}onlyIncludeVersions</patterns>Full example: See examples/customization.md for version banner configuration and multi-version navigation.
How should the sidebar be organized?
|-- Small docs site (< 30 pages)?
| +-- Use autogenerated sidebar with sidebar_position front matter
|-- Large docs site with many sections?
| |-- Sections map cleanly to directories? -> Autogenerated + _category_.json
| +-- Need cross-directory grouping? -> Manual sidebar in sidebars.js
|-- Multiple independent doc sets (e.g., API + guides)?
| +-- Use multiple docs plugin instances, each with its own sidebar
+-- Need to mix auto and manual?
+-- Use autogenerated for most, with manual items for special entriesNeed to customize a theme component?
|-- Adding content around the component? -> Wrap (--wrap)
|-- Need to change the component's internal logic? -> Check safety level first
| |-- Component marked "Safe"? -> Eject is acceptable
| |-- Component marked "Unsafe"? -> Wrap if possible, eject only as last resort
| +-- Component marked "Forbidden"? -> Do not swizzle — find another approach
+-- Just changing colors/spacing? -> Use CSS variables in custom.css (no swizzle needed)What kind of page am I creating?
|-- Documentation article? -> .md or .mdx file in docs/
|-- Blog post? -> .md or .mdx file in blog/
|-- Standalone page with custom layout?
| |-- Mostly content? -> .mdx in src/pages/
| +-- Mostly interactive/React? -> .tsx in src/pages/
+-- Need to embed React components in docs? -> Use .mdx with importsonBrokenLinks: 'ignore''log''throw'@theme/ComponentName@theme-original/ComponentNamesidebars.jsonBrokenMarkdownLinks: 'warn'editUrlshowLastUpdateTime: true{<\{\<docusaurus.config.js.mdformat: 'detect'.mdx_category_.jsonnamelabelorderposition@docusaurus/@theme/@site/baseUrl/static/baseUrlrequire()useBaseUrl()blog/authors.ymldocusaurus.config.jsslugdocs-only moderouteBasePath: '/'blog: falsesrc/pages/src/pages/support.tsx/supportgroupIdAll code must follow project conventions in CLAUDE.md
docusaurus.config.js@docusaurus/preset-classic--wrap--ejectsidebar_position_category_.json