Docusaurus DocsSitemap with Two-Column Landing Page
Add a two-column landing page layout: left sticky sidebar (title, tagline, logo, links) + right column with expand/collapse DocsSitemap.
Prerequisites
- •
gray-matterandclsxnpm dependencies - •Docusaurus site with
sidebars.ts(or.js)
Step 1: Detect Docusaurus Root
Find the directory containing docusaurus.config.ts (or docusaurus.config.js). This is the Docusaurus root directory, referred to as {DOCUSAURUS_ROOT} in the steps below. All file paths in this skill are relative to this root.
Step 2: Create doc-titles generation script
Same as /docusaurus-doc-title skill. Create {DOCUSAURUS_ROOT}/scripts/generate-doc-titles.js that scans all markdown files and outputs src/data/doc-titles.json.
Step 3: Create the DocsSitemap component
Create {DOCUSAURUS_ROOT}/src/components/DocsSitemap/index.tsx that reads sidebars.ts and doc-titles.json, rendering each sidebar as a collapsible <details>/<summary> section.
Key features:
- •
generateLabel()converts sidebar IDs to display names (e.g.,inboxSidebar->INBOX) - •Handles
autogeneratedsidebars by resolving docs fromdoc-titles.jsonbydirName/prefix - •Animated chevron rotates on open
- •Each section is open by default
Step 4: Copy the logo SVG
Copy the bundled logo from this skill's assets to the target project:
{SKILL_DIR}/assets/logo.svg → {DOCUSAURUS_ROOT}/static/img/logo.svg
If static/img/logo.svg already exists in the target project, keep the existing one (it may be project-specific). Only copy if no logo exists.
Step 5: Create the two-column landing page
Read assets/index.tsx from this skill directory and copy it to:
{DOCUSAURUS_ROOT}/src/pages/index.tsx
Read assets/index.module.css from this skill directory and copy it to:
{DOCUSAURUS_ROOT}/src/pages/index.module.css
If an existing src/pages/index.js redirect file exists, remove it (it conflicts with index.tsx).
After copying, customize the links section in index.tsx for the project (title, URLs).
Step 6: Update config
In docusaurus.config.ts (or .js):
- •Ensure
routeBasePathis/docs(not/) - •Update search plugin's
docsRouteBasePathto/docsif applicable
Delete docs/intro.md if it has slug: /.
Step 7: Wire up scripts and gitignore
In package.json:
"start": "pnpm run generate && docusaurus start", "build": "pnpm run generate && docusaurus build", "generate": "pnpm run generate:doc-titles", "generate:doc-titles": "node scripts/generate-doc-titles.js"
Add to .gitignore:
src/data/doc-titles.json
Install gray-matter if not already present.
Step 7: Verify
Run pnpm run generate then pnpm run build. Verify:
- •Landing page shows two-column layout with logo on the left
- •Logo appears inside an orange rounded-corner container, white-inverted
- •Right column shows expandable sidebar sections with all doc links
- •Responsive: single column on mobile (< 996px)
- •Left column is sticky on scroll
Assets
- •
assets/logo.svg- Default logo SVG. Target:{DOCUSAURUS_ROOT}/static/img/logo.svg - •
assets/index.tsx- Landing page component with two-column layout. Target:{DOCUSAURUS_ROOT}/src/pages/index.tsx - •
assets/index.module.css- Landing page CSS module. Target:{DOCUSAURUS_ROOT}/src/pages/index.module.css