Setting Up a New Docusaurus Repository
This guide walks you through setting up a new Docusaurus repository with all the features and best practices from the Pacing Agency tech stack documentation.
Features Included
- ✅ Tool Categorization System - Automatic organization of tools by category with cost tracking
- ✅ ToolMetadata Component - Visual metadata cards on tool pages
- ✅ CategorySummary Component - Category page summaries with aggregated costs
- ✅ ToolsOverview Component - Interactive expandable overview on main tools page
- ✅ Sections Configuration - Centralized management of documentation sections
- ✅ Mermaid Diagrams - Visual diagramming support
- ✅ FAQ Structured Data - SEO-friendly FAQ component with toggleable structured data
- ✅ Auto-sync Script - Automatic sync of tool documentation with categorization
- ✅ Feature Toggles - Configurable features for internal vs external documentation
Prerequisites
- Node.js >= 20.0
- npm (comes with Node.js)
- Git
- A GitHub repository (for deployment)
Step 1: Initialize Docusaurus
npx create-docusaurus@latest my-docs classic
cd my-docs
Step 2: Install Dependencies
npm install @docusaurus/theme-mermaid
Step 3: Configure Docusaurus
Update docusaurus.config.ts:
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
const config: Config = {
title: 'Your Documentation Site',
tagline: 'Documentation for your project',
url: 'https://your-site.com',
baseUrl: '/',
// Feature flags
customFields: {
features: {
documentationType: 'internal', // or 'external' for public sites
enableFAQStructuredData: true, // Enable FAQ structured data
enableMermaid: true, // Enable Mermaid diagrams
},
},
presets: [
[
'classic',
{
docs: {
sidebarPath: './sidebars.ts',
},
blog: {
showReadingTime: true,
},
theme: {
customCss: './src/css/custom.css',
},
} satisfies Preset.Options,
],
],
themes: ['@docusaurus/theme-mermaid'],
markdown: {
mermaid: true,
},
themeConfig: {
mermaid: {
theme: {
light: 'default',
dark: 'dark',
},
options: {
maxTextSize: 50000,
},
},
} satisfies Preset.ThemeConfig,
};
export default config;
Step 4: Add FAQ Structured Data Component
- Create directory structure:
mkdir -p src/theme/MDXComponents/FAQStructuredData
-
Copy component files:
- Copy
src/theme/MDXComponents/FAQStructuredData/index.js - Copy
src/theme/MDXComponents/FAQStructuredData/types.d.ts
From this repository or create them based on the FAQ Structured Data documentation.
- Copy
Step 5: Add Auto-Sync Script (Optional)
If you want to auto-sync documentation from a tools/ directory:
- Create sync script:
mkdir -p scripts
-
Copy
scripts/sync-tools.cjsfrom this repository -
Add to
package.json:
{
"scripts": {
"prebuild": "node scripts/sync-tools.cjs",
"build": "docusaurus build",
"start": "docusaurus start"
}
}
Step 6: Feature Toggle Configuration
Internal Documentation
For internal documentation (no SEO needed):
// docusaurus.config.ts
customFields: {
features: {
documentationType: 'internal',
enableFAQStructuredData: false, // No structured data needed
enableMermaid: true,
},
},
Usage in MDX:
import FAQStructuredData from '@site/src/theme/MDXComponents/FAQStructuredData';
<FAQStructuredData
faqs={faqs}
includeStructuredData={false}
/>
External/Public Documentation
For public-facing sites (SEO important):
// docusaurus.config.ts
customFields: {
features: {
documentationType: 'external',
enableFAQStructuredData: true, // Enable structured data for SEO
enableMermaid: true,
},
},
Usage in MDX:
import FAQStructuredData from '@site/src/theme/MDXComponents/FAQStructuredData';
<FAQStructuredData
faqs={faqs}
includeStructuredData={true}
/>
Step 7: Create Feature Documentation
Create a docs/features/ directory and add:
faq-structured-data.md- FAQ component documentationmermaid-diagrams.md- Mermaid diagram guide (or link totools/mermaid.md)setup-new-repo.md- This file
Step 8: Deployment
Cloudflare Pages
- Connect repository to Cloudflare Pages
- Configure build settings:
- Framework preset: Docusaurus
- Build command:
npm run build - Build directory:
build - Root directory:
docusaurus(if using monorepo structure)
GitHub Pages
- Install
gh-pages:
npm install --save-dev gh-pages
- Add deploy script to
package.json:
{
"scripts": {
"deploy": "docusaurus deploy"
}
}
- Configure
docusaurus.config.ts:
const config: Config = {
// ... other config
organizationName: 'your-org',
projectName: 'your-repo',
};
Feature Checklist
Use this checklist when setting up a new repository:
- Docusaurus initialized
- Mermaid theme installed and configured
- FAQ Structured Data component added
- Feature flags configured in
docusaurus.config.ts - Auto-sync script added (if needed)
- Feature documentation created
- Deployment configured (Cloudflare Pages or GitHub Pages)
- Structured data tested (for external sites)
Testing Features
Test Mermaid Diagrams
Create a test page with a Mermaid diagram:
# Test Mermaid
```mermaid
graph TD
A[Start] --> B[End]
### Test FAQ Component
Create a test page with FAQs:
```mdx
import FAQStructuredData from '@site/src/theme/MDXComponents/FAQStructuredData';
export const faqs = [
{
question: 'Test Question?',
answer: 'Test Answer',
},
];
<FAQStructuredData faqs={faqs} />
Test Structured Data (External Sites)
- Deploy your site
- Visit Google Rich Results Test
- Enter your page URL
- Verify FAQ structured data is detected
Troubleshooting
FAQ Component Not Found
- Ensure the component files are in
src/theme/MDXComponents/FAQStructuredData/ - Check the import path matches your directory structure
- Verify the component is exported correctly
Mermaid Diagrams Not Rendering
- Verify
@docusaurus/theme-mermaidis installed - Check
themes: ['@docusaurus/theme-mermaid']is in config - Ensure
markdown: { mermaid: true }is set
Structured Data Not Valid
- Use Google Rich Results Test to validate
- Check that
includeStructuredData={true}is set - Verify FAQ objects have both
questionandanswerproperties
Next Steps
- Customize theme - Update colors, fonts, and branding
- Add content - Create your documentation pages
- Configure search - Set up Algolia DocSearch (optional)
- Set up CI/CD - Automate deployments
- Add analytics - Configure tracking (if needed)