Material for MkDocs Cheat Sheet¶
1. Overview & Installation¶
What is MkDocs?¶
- Static site generator for documentation
- Written in Python
- Uses Markdown
- Generates HTML
What is Material for MkDocs?¶
- Modern theme for MkDocs
- Adds search, tabs, admonitions, icons, Mermaid, dark mode, versioning and more.
Installation¶
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
pip install mkdocs
pip install mkdocs-material
Create project
Run locally
Build
Deploy
2. Project Structure¶
project/
├── docs/
│ ├── index.md
│ ├── guide.md
│ ├── images/
│ └── api/
├── overrides/
├── site/
├── mkdocs.yml
└── requirements.txt
| Folder | Purpose |
|---|---|
| docs | Documentation |
| images | Images |
| overrides | HTML overrides |
| site | Generated website |
| mkdocs.yml | Configuration |
3. mkdocs.yml Essentials¶
site_name: My Docs
site_url: https://example.com
theme:
name: material
nav:
- Home: index.md
- Apache: apache.md
plugins:
- search
markdown_extensions:
- admonition
- footnotes
- tables
- pymdownx.details
- pymdownx.superfences
Recommended settings: - site_name - nav - theme - palette - logo - favicon - repo_url - plugins - extra_css - extra_javascript
4. Markdown Essentials¶
Headings¶
Table¶
Image¶
Internal Link¶
Code¶
Footnotes¶
5. Material Components¶
Admonition¶
Collapsible¶
Tabs¶
Task List¶
Keyboard¶
Icon¶
6. Mermaid¶
Flowchart¶
Sequence¶
ER Diagram¶
7. Useful Plugins¶
| Plugin | Purpose |
|---|---|
| search | Search |
| awesome-pages | Navigation |
| macros | Variables |
| redirects | Redirects |
| blog | Blog |
| tags | Tags |
| social | Social cards |
| glightbox | Image zoom |
| mike | Versioning |
Install
Enable
8. Customization¶
CSS
JavaScript
Dark Mode
Logo
9. Deployment¶
GitHub Pages
Apache
Nginx
Docker
10. Daily Reference¶
Commands¶
Common Extensions¶
markdown_extensions:
- admonition
- attr_list
- footnotes
- tables
- toc
- pymdownx.details
- pymdownx.superfences
- pymdownx.tabbed
- pymdownx.highlight
- pymdownx.keys
- pymdownx.emoji
Suggested Documentation Layout¶
docs/
├── index.md
├── linux/
├── apache/
├── mysql/
├── python/
├── php/
├── api/
├── security/
├── architecture/
├── runbooks/
├── troubleshooting/
└── images/
Documentation Checklist¶
- Purpose
- Installation
- Configuration
- Examples
- Diagrams
- Troubleshooting
- FAQ
- References