MkDocs Material Documentation Setup¶
Complete guide to creating your own personal documentation site using MkDocs Material, GitHub Pages, and Claude Code for automated management.
Overview¶
This guide walks you through creating a documentation site that:
- Uses MkDocs Material theme for beautiful, modern documentation
- Automatically deploys to GitHub Pages via GitHub Actions
- Is managed entirely by Claude Code using the GitHub CLI
- Includes a local development server in a virtual environment
- Auto-restarts the server after each commit for live testing
Prerequisites¶
Before starting, ensure you have:
- GitHub account with SSH authentication configured
- GitHub CLI (
gh) installed and authenticated - Claude Code installed and configured
- Git configured with your name and email
- SSH key added to your GitHub account
Verify Prerequisites
1 2 3 4 5 6 7 8 9 | |
Step 1: Create GitHub Repository¶
Create a new repository for your documentation using the GitHub CLI:
1 2 3 4 5 | |
Repository Naming:
- Suggested name: dok (short for "documentation")
- Alternative names: docs, my-docs, knowledge-base
- The repository name doesn't affect the final site URL
Step 2: Clone Repository¶
Clone your new repository using SSH:
1 2 3 4 5 6 7 8 | |
Step 3: Create README.md¶
Create a README.md file that explains your intent to use Claude Code for managing the documentation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
Step 4: Launch Claude Code¶
Now start Claude Code to initialize your documentation project:
1 2 | |
Step 5: Run /init Command¶
Once Claude Code is running, execute the /init command:
1 | |
What /init Does:
The /init command will analyze your repository and README.md, then:
- Create CLAUDE.md - Guidance file for future Claude Code sessions
- Generate mkdocs.yml - MkDocs configuration with Material theme
- Create docs/ Structure - Documentation directory with initial pages
- Set up GitHub Actions - Workflow for automatic deployment
- Initialize Virtual Environment - Python venv at .venv/
- Install Dependencies - mkdocs and mkdocs-material packages
- Start Development Server - Local server at http://127.0.0.1:8000/
Example /init Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Step 6: Working with Your Documentation¶
Making Changes¶
Claude Code manages your documentation workflow:
Adding Content:
1 | |
Updating Configuration:
1 | |
Modifying Theme:
1 | |
Automatic Server Management¶
Claude Code automatically manages the development server:
- After Initialization: Server starts in .venv and runs continuously
- After Commits: Server is killed and restarted with fresh changes
- After Errors: Server is restarted if it crashes or encounters issues
This ensures you always see the latest changes at http://127.0.0.1:8000/
Committing Changes¶
When you're ready to commit, Claude Code will:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Project Structure¶
After initialization, your repository will have this structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
GitHub Actions Deployment¶
The deployment workflow (.github/workflows/deploy.yml) automatically:
- Triggers on every push to
mainbranch - Sets up Python 3.12
- Installs mkdocs and mkdocs-material
- Builds the documentation site
- Deploys to
gh-pagesbranch - Makes site available at:
https://YOUR_USERNAME.github.io/dok/
Deployment Workflow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
Viewing Your Site¶
Local Development¶
While working on documentation:
- URL: http://127.0.0.1:8000/
- Live Reload: Changes appear automatically
- Server Management: Claude Code handles start/stop/restart
Published Site¶
After pushing to GitHub:
- GitHub Actions builds and deploys (takes 1-2 minutes)
- Site becomes available at:
https://YOUR_USERNAME.github.io/dok/ - Updates appear within minutes of pushing changes
Check Deployment Status
1 2 3 4 5 6 7 8 | |
Common Commands¶
Local Development¶
1 2 3 4 5 6 7 8 | |
Repository Management via Claude Code¶
Instead of running commands manually, ask Claude Code:
1 | |
1 | |
1 | |
1 | |
MkDocs Material Features¶
Your documentation site includes these Material theme features:
Navigation¶
- Instant loading - Fast page transitions
- Navigation tabs - Top-level sections in tabs
- Sticky navigation - Navigation stays visible while scrolling
- Table of contents - Right sidebar with page sections
Search¶
- Search suggestions - As-you-type search suggestions
- Search highlighting - Highlights search terms in results
- Search sharing - Share search results via URL
Content¶
- Code highlighting - Syntax highlighting with line numbers
- Code copying - One-click code block copying
- Admonitions - Call-out boxes for notes, warnings, tips
- Task lists - Interactive checkboxes in markdown
Appearance¶
- Dark/Light mode - Automatic theme switching
- Color customization - Configurable primary and accent colors
- Typography - Beautiful, readable fonts
- Responsive design - Works on all device sizes
Customization¶
Theme Colors¶
Ask Claude Code to update colors in mkdocs.yml:
1 | |
Adding Sections¶
Structure your documentation by topic:
1 2 3 4 | |
Custom Homepage¶
Customize docs/index.md as your landing page:
1 2 3 4 | |
Troubleshooting¶
Server Won't Start¶
If the development server fails to start:
1 | |
Claude Code will: 1. Check if port 8000 is in use 2. Verify virtual environment is set up correctly 3. Check mkdocs installation 4. Restart the server on an alternative port if needed
Deployment Failures¶
If GitHub Actions deployment fails:
1 | |
Claude Code will:
1. Fetch workflow logs using gh run view --log
2. Identify the error
3. Fix the issue (usually dependencies or configuration)
4. Commit and push the fix
Build Errors¶
If mkdocs build reports errors:
1 | |
Common issues: - Broken links in markdown files - Missing files referenced in navigation - Invalid YAML in mkdocs.yml - Malformed markdown syntax
Best Practices¶
Documentation Structure¶
Organize content logically:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Writing Content¶
- Clear headings: Use descriptive section titles
- Code examples: Include practical, working examples
- Screenshots: Add images to docs/images/ directory
- Links: Use relative links between pages
- Search keywords: Include relevant terms for searchability
Git Workflow¶
Let Claude Code manage commits:
- Descriptive messages: Claude Code writes clear commit messages
- Logical grouping: Related changes committed together
- Automatic pushing: Changes deploy immediately after commit
Server Management¶
Trust Claude Code to handle the server:
- Starts automatically after
/init - Restarts after commits for testing
- Runs in background without terminal blocking
- Uses .venv for clean dependency isolation
Advanced Topics¶
Custom Domain¶
To use a custom domain (e.g., docs.example.com):
-
Add CNAME file to docs/ directory:
1echo "docs.example.com" > docs/CNAME -
Configure DNS:
1CNAME record: docs.example.com → YOUR_USERNAME.github.io -
Update
site_urlin mkdocs.yml:1site_url: https://docs.example.com/
Additional Plugins¶
Ask Claude Code to add plugins:
1 | |
1 | |
Common plugins:
- mkdocs-awesome-pages-plugin - Flexible page ordering
- mkdocs-mermaid2-plugin - Mermaid diagram rendering
- mkdocs-git-revision-date-localized-plugin - Last updated timestamps
- mkdocs-minify-plugin - Minify HTML/CSS/JS
Multiple Repositories¶
Create separate documentation sites for different projects:
1 2 3 4 5 6 7 8 9 | |
Each repository gets its own:
- GitHub Pages site at YOUR_USERNAME.github.io/REPO_NAME/
- Development server on localhost
- Independent content and configuration
Example: This Documentation Site¶
This very documentation site you're reading was created using this exact process:
- Created repository:
dirkpetersen/dok - Cloned via SSH
- Wrote README.md describing documentation goals
- Launched Claude Code and ran
/init - Claude Code created:
- CLAUDE.md with project guidance
- mkdocs.yml with Material theme configuration
- docs/ structure with shell, cloud, and code-pasting sections
- GitHub Actions workflow for deployment
- Virtual environment and local server
The entire site is managed by Claude Code: - All commits made via Claude Code - Server automatically restarts after changes - Documentation organized into logical sections - Deployed automatically to GitHub Pages
View the source: github.com/dirkpetersen/dok
Summary¶
Creating a personal documentation site with Claude Code:
- Create repo:
gh repo create dok --public - Clone:
git clone git@github.com:USERNAME/dok.git - Write README.md: Describe documentation intent and topics
- Launch Claude Code:
claude - Initialize: Run
/initcommand - Develop: Ask Claude Code to add content, make changes
- Automatic deployment: Push triggers GitHub Actions
- Live site: Available at
https://USERNAME.github.io/dok/
Claude Code handles: - Project structure creation - Virtual environment setup - Server start/stop/restart - Git commits and pushes - Configuration updates - Content organization
You focus on: - Describing what you want - Reviewing changes - Writing content (with Claude Code's help)
The result: beautiful, automatically-deployed documentation with minimal manual work.