Mkdocs
全球最大的 Claude Code 技能聚合库 · 收录 3900+ 来自 12+ 来源的技能,提供在线搜索与趋势分析看板 / The world's largest Claude Code skill aggregation hub — 3900+ skills from 12+ sources with online search and trend dashboard
npx -y skills add bg-szy/TOP-SKILLS --skill mkdocsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Build project documentation sites with MkDocs static site generator. USE WHEN user mentions mkdocs, documentation site, docs site, project documentation, OR wants to create, configure, build, or deploy documentation using Markdown. Covers installation, configuration, theming, plugins, and deployment.
SKILL.md
7.9 KB, as published. Nobody here has run it
MkDocs Documentation Site Generator
MkDocs is a fast, simple static site generator for building project documentation from Markdown files. Configuration uses a single YAML file (mkdocs.yml).
Quick Start
Installation
# Install MkDocs
pip install mkdocs
# Verify installation
mkdocs --version
Create New Project
# Create project structure
mkdocs new my-project
cd my-project
# Start development server
mkdocs serve
Project Structure Created:
my-project/
├── mkdocs.yml # Configuration file
└── docs/
└── index.md # Homepage
Minimal Configuration
# mkdocs.yml
site_name: My Project
site_url: https://example.com/
nav:
- Home: index.md
- About: about.md
Core Commands
| Command | Purpose |
|---|---|
mkdocs new PROJECT | Create new project |
mkdocs serve | Start dev server (localhost:8000) |
mkdocs build | Build static site to site/ |
mkdocs gh-deploy | Deploy to GitHub Pages |
mkdocs get-deps | Show required packages |
Common Options:
-f, --config-file FILE- Use custom config file-s, --strict- Fail on warnings-d, --site-dir DIR- Custom output directory--dirty- Only rebuild changed files--clean- Clean output before build
Project Structure
project/
├── mkdocs.yml # Configuration (required)
├── docs/
│ ├── index.md # Homepage
│ ├── about.md # Additional pages
│ ├── user-guide/
│ │ ├── index.md # Section homepage
│ │ ├── getting-started.md
│ │ └── configuration.md
│ ├── img/ # Images
│ │ └── logo.png
│ └── css/ # Custom CSS
│ └── extra.css
└── custom_theme/ # Theme customizations (optional)
└── main.html
Navigation Configuration
# Automatic navigation (alphabetically sorted)
# Omit nav key to auto-generate
# Explicit navigation with sections
nav:
- Home: index.md
- User Guide:
- Getting Started: user-guide/getting-started.md
- Configuration: user-guide/configuration.md
- API Reference: api/
- External Link: https://example.com/
Writing Documentation
Internal Links
# Link to another page
[See Configuration](configuration.md)
# Link to page in another directory
[Installation](../getting-started/installation.md)
# Link to section anchor
[See Options](configuration.md#options)
Page Metadata
---
title: Custom Page Title
description: Page description for SEO
authors:
- John Doe
date: 2024-01-01
---
# Page Content Here
Code Blocks
```python
def hello():
print("Hello, World!")
```
Tables
| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1 | Cell 2 |
Theme Configuration
Built-in Themes
# Default MkDocs theme
theme:
name: mkdocs
color_mode: auto # light, dark, auto
user_color_mode_toggle: true
nav_style: primary # primary, dark, light
highlightjs: true
navigation_depth: 2
locale: en
# ReadTheDocs theme
theme:
name: readthedocs
prev_next_buttons_location: bottom
navigation_depth: 4
collapse_navigation: true
Material for MkDocs (Popular Third-Party)
pip install mkdocs-material
theme:
name: material
palette:
primary: indigo
accent: indigo
features:
- navigation.tabs
- navigation.sections
- search.suggest
Custom CSS/JavaScript
extra_css:
- css/extra.css
extra_javascript:
- js/extra.js
- path: js/analytics.mjs
type: module
Plugins
plugins:
- search:
lang: en
min_search_length: 3
- tags
- blog
Popular Plugins:
search- Full-text search (built-in, enabled by default)blog- Blog functionality (Material theme)tags- Content categorizationsocial- Social media cards
Note: Defining
pluginsdisables defaults. Add- searchexplicitly.
Markdown Extensions
markdown_extensions:
- toc:
permalink: true
separator: "-"
- tables
- fenced_code
- admonition
- pymdownx.highlight
- pymdownx.superfences
Deployment
GitHub Pages
# Deploy to gh-pages branch
mkdocs gh-deploy
# With options
mkdocs gh-deploy --force --message "Deploy docs"
Build for Any Host
# Build static files
mkdocs build
# Files output to site/ directory
# Upload to any static host
Custom Domain
Create docs/CNAME file:
docs.example.com
Common Workflows
New Documentation Project
- Create project:
mkdocs new my-docs - Edit
mkdocs.ymlwith site_name and nav - Add Markdown files to
docs/ - Preview:
mkdocs serve - Build:
mkdocs build - Deploy:
mkdocs gh-deploy
Quick Build Preview
Bash(mkdocs build --dry-run)
If clean: Bash(mkdocs serve -v) (dev preview).
Add New Section
- Create directory:
docs/new-section/ - Add
index.mdand content files - Update
navinmkdocs.yml - Preview and verify links
Customize Theme
- Set
theme.custom_dir: custom_theme/ - Create override files matching theme structure
- Use template blocks to extend base templates
Safe Preview Workflow
- Check MkDocs:
Bash(which mkdocs || echo "Install: pip install mkdocs") - Dry-run build:
Bash(mkdocs build --dry-run) - List issues:
Grep -r "ERROR" site/
Detailed References
- Configuration options: See references/configuration.md
- Theme customization: See references/themes.md
- Plugin development: See references/plugins.md
- Deployment strategies: See references/deployment.md
- Best practices: See references/best-practices.md
Gotchas
mkdocs servewatchesdocs/andmkdocs.ymlbut NOT files included viainclude_diror theme overrides — edits tocustom_theme/main.htmldon't trigger reload. Restart the server.- Defining
plugins:in mkdocs.yml disables the default search plugin — pages stop being indexed and the search box returns nothing. Always include- searchexplicitly when listing plugins. mkdocs gh-deployforce-pushes togh-pages— any manual edits or other branches deployed there get destroyed silently. Use--no-historyfor clean history but never editgh-pagesby hand.use_directory_urls: true(default) changes link semantics:page.mdbecomespage/notpage.html. Relative links in raw Markdown that worked locally as files break on the deployed site.strict: truefails on warnings including unrecognized config keys — adding a Material-theme-only option to a config that uses the default theme fails the build, not just warns. Check theme compatibility before enabling strict.- Material theme's
navigation.instantfeature breaks third-party JS that runs on page load — analytics, Mermaid, MathJax all need explicitdocument$.subscribe()hooks instead ofDOMContentLoaded. mkdocs build --dirtyskips unchanged files but doesn't detect changes to navigation or theme config — pages render with stale nav. Use--clean(default) or deletesite/when in doubt.