Docusaurus Setup Skill
What This Skill Does
- •Project Analysis - Examine Docusaurus structure and dependencies
- •Local Configuration Validation - Verify Docusaurus config and sidebars
- •Local Build & Testing - Build site locally and validate output
- •Content Verification - Check for broken links and syntax errors
- •GitHub Pages Setup - Configure repository and deployment settings
- •CI/CD Automation - Set up GitHub Actions workflows
- •Deployment Verification - Validate successful deployment
When to Use This Skill
- •Deploy the Docusaurus site on github pages.
- •perform
git add .,git commit -m "update site - [detail]"andgit push -u origin mainoperation - •You’re configuring if not already set
docusaurus.config.js(title, baseUrl, theme plugins, navbar, footer). - •You’re editing
sidebars.jsto match your course or project structure. - •You need to set up deployment of a Docusaurus site to GitHub Pages with CI/CD.
How This Skill Works
- •
Confirm build output:
- •Run
npm run buildlocally to ensure the site compiles without errors and outputs tobuild/. - •Fix any configuration issues (e.g., broken links or missing assets) before proceeding.
- •Run
- •
Configure
docusaurus.config.jsif not already set:- •Minimal Configuration Tip: Focus on
url,baseUrl,organizationName,projectName, anddeploymentBranchfor initial setup. - •Open
docusaurus.config.tsand check these fields:- •
url: Should behttps://<github-username>.github.io. - •
baseUrl: Should be"/<repo-name>/"if the project is not served from root. - •
organizationNameandprojectName: Match your GitHub account and repository. - •
deploymentBranch: Usuallygh-pages. - •Optional fields like
trailingSlash,i18nsettings andfaviconshould reflect the project’s needs.
- •
- •Customize the navbar and footer links to mirror the course modules and external resources.
- •Add or remove plugins (e.g., search, analytics) as needed for your use case.
- •Security Note: Avoid hardcoding sensitive information directly. Use environment variables (e.g.,
.envfiles or GitHub Secrets) for tokens or other confidential data.
- •Minimal Configuration Tip: Focus on
- •
Edit
sidebars.js:- •Minimal Configuration Tip: Define a basic structure with your main content categories.
- •Define the sidebar structure to reflect the course outline or document hierarchy.
- •Group chapters and sections logically, using categories for modules and weeks.
- •Ensure that sidebars update automatically when new Markdown/MDX files are added.
- •
Theme customization:
- •Adjust styling via
@themecomponents or CSS for consistent colors and typography. - •Override theme components in the
src/themedirectory (e.g., custom layout or code block styles). - •Test changes locally using
npm run startto ensure responsiveness.
- •Adjust styling via
- •
Prepare for GitHub Pages deployment:
- •Initialize a Git repository and connect it to GitHub using the GitHub CLI (e.g.,
gh repo create <repo> --public). - •Push the initial site to the repository.
- •In
docusaurus.config.js, set theorganizationName,projectName, anddeploymentBranchfields to match your GitHub org/user and repository. - •Important: If GitHub Pages is not yet enabled for your repository, run
gh pages enable --branch gh-pagesvia the GitHub CLI.
- •Initialize a Git repository and connect it to GitHub using the GitHub CLI (e.g.,
- •
Set up CI/CD pipeline:
- •Check if
.github/workflows/deploy.ymlexists in the repository. - •If it doesn’t exist or needs updating, create it with a workflow similar to:
yamlname: Deploy Docusaurus to GitHub Pages on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '18' - run: npm ci - run: npm run build - uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./build publish_branch: gh-pages- •Checks out the repository.
- •Installs Node dependencies (e.g., using
actions/setup-node). - •Builds the static site (
npm run build). - •Deploys the contents of
buildto thegh-pagesbranch usingactions-gh-pagesorghCLI.
- •Commit and push the workflow to the default branch; GitHub Actions will handle future deployments on push.
- •Check if
- •
Deployment Verification (New Content/Updates):
- •Run
npm run startlocally to verify site appearance. - •Commit your changes:
- •
git add . - •
git commit -m "Update site - [detail of changes]" - •
git push origin main(or your default branch)
- •
- •After the GitHub Actions workflow finishes, the site will be available at
https://<username>.github.io/<repo>/. - •Make adjustments to configuration files if deployment fails (e.g., baseUrl mismatch).
- •Once completed, visit
https://<github-username>.github.io/<repo-name>/to confirm your updated book is live.
- •Run
- •
Ongoing usage:
- •Each time new content is committed, the workflow automatically redeploys the site.
Performance Targets
- •Build time: < 30 seconds (typical)
- •Page load: < 3 seconds
- •Bundle size: Optimized for documentation
- •Accessibility: WCAG 2.1 AA compliance
Quality Gates (Constitution v3.1.2)
Before deployment to production, verify:
- • All content passes validation-auditor validation
- • Local build completes without errors
- • No broken links or missing resources
- • TypeScript type checking passes
- • Performance targets met
- • Accessibility standards verified
- • GitHub Actions workflow configured correctly
Output Format
When using this skill, provide:
- •A clear repository name and the desired site name.
- •Any custom sections or modules to include in
sidebars.js. - •Details about theme changes (e.g., custom color palette, fonts).
- •Confirmation that the GitHub CLI is authenticated on your machine.
The skill will return:
- •Project Setup Summary: Path to the new Docusaurus project and commands executed.
- •Configuration Details: A checklist of changes made to
docusaurus.config.jsandsidebars.js. - •Confirmation Deploy.yml: Confirmation of whether
.github/workflows/deploy.ymlalready existed or was created. - •CI/CD Instructions: A ready-to-commit
deploy.ymlworkflow for GitHub Actions and notes on enabling GitHub Pages. - •Next Steps:
- •First find the Docusaurus project folder
cd <project_folder_name> - •How to add content to the
docsorblogfolders inside Docusaurus project and verify deployment.
Example
Input: “I just added a new chapter and want to publish the updated Docusaurus site.”
Output:
- •Config Check: Verified
urlishttps://jane-doe.github.io,baseUrlis/physical-ai-book/, anddeploymentBranchisgh-pages. No changes needed. - •Configuration Details: Updated site title to “Robotics Course Book,” , added modules to
sidebars.js(Module 1: ROS 2, Module 2: Digital Twin…). - •Workflow Creation: Added
.github/workflows/deploy.ymlfor automatic deployment on pushes tomain. - •Next Steps: Add your markdown chapters to
docs/,Runnpm run buildlocally if desired, commit all changes (git add .andgit commit -m "Add Chapter 3 and deployment pipeline"), and push (git push origin main). After the GitHub Actions workflow finishes, the site will be available athttps://<github-username>.github.io/physical-ai-book/.