-
@ avren
2025-05-07 07:16:54๐ ๏ธ MkDocs on macOS
For my local documentation, I was looking for an open-source tool to create and manage my content. With MkDocs, I found a mature, widely used, and actively maintained solution.
I think this tool is worth writing an article about. Iโm still new to it and donโt have much experience yet. What tools do you use to create your documentation locally?
๐ What is MkDocs?
MkDocs is an open source tool for building static websites from Markdown files, designed specifically for technical documentation.
โ Key Features
| Feature | Description | |---------------------------|----------------------------------------------------------------------------| | ๐ Markdown-based | Write content in
.md
files (e.g., with Zettlr, VS Code, Obsidian) | | ๐ Static site output | MkDocs renders a full HTML site with navigation, search, and styling | | ๐จ Themes available | Most popular: Material for MkDocs | | ๐ Live preview | Usemkdocs serve
to view the docs locally in your browser | | ๐ง Simple configuration | Controlled via a singlemkdocs.yml
file | | ๐ No cloud required | Fully local, ideal for privacy and offline work |
๐ฆ Is MkDocs open source?
Yes. MkDocs is fully open source and licensed under the MIT License โ free to use, modify, and redistribute.
- ๐ GitHub: github.com/mkdocs/mkdocs
- ๐ PyPI: pypi.org/project/mkdocs
๐ง What can you build with MkDocs?
Examples include:
- Internal IT or team documentation
- Project or API documentation (e.g., GitHub projects)
- Manuals, Wikis, or checklists
- Offline technical knowledge bases
โ Requirements
- macOS (e.g., Ventura, Sonoma)
- Terminal basics
- Python installed
๐ง Step 1: Install MkDocs
Install MkDocs locally for your user:
bash pip3 install --user mkdocs
(Optional) Add the Material theme:
bash pip3 install --user mkdocs-material
This gives your documentation a modern, responsive design.
๐งญ Step 2: Make the
mkdocs
command availableBy default, pip installs MkDocs in a directory not included in your PATH. To fix that:
a) Check install location:
bash python3 -m site --user-base
Example output:
/Users/yourname/Library/Python/3.11
The relevant binary path is:
/Users/yourname/Library/Python/3.11/bin
b) Add to PATH permanently (zsh):
bash echo 'export PATH=$PATH:/Users/yourname/Library/Python/3.11/bin' >> ~/.zshrc source ~/.zshrc
Replace Python version if needed (
3.11
).
๐ Step 3: Start a new MkDocs project
bash mkdocs new my-docs cd my-docs mkdocs serve
Now open: http://127.0.0.1:8000
๐จ Step 4: Enable the Material Theme
Edit
mkdocs.yml
:yaml theme: name: material
Then restart:
bash mkdocs serve
๐งฉ Alternative: Run via Python module
If you see this error:
zsh: command not found: mkdocs
โฆ you can always run MkDocs via:
bash python3 -m mkdocs serve
๐ MkDocs Awesome Pages Plugin
The
awesome-pages
plugin for MkDocs automatically builds navigation from your folder structure โ no need to manually definenav:
inmkdocs.yml
.
โ Open Source
- License: MIT
- Repo: github.com/lukasgeiter/mkdocs-awesome-pages-plugin
๐ ๏ธ Installation
Install with pip:
bash pip3 install mkdocs-awesome-pages-plugin
โ๏ธ Configure
mkdocs.yml
Add the plugin:
yaml plugins: - search - awesome-pages
โ ๏ธ Remove the
nav:
section if you use this plugin โ it will otherwise be ignored.
๐ Folder structure &
.pages
filesNavigation is based on the folder structure under
docs/
.Example structure:
docs/ โโโ index.md โโโ installation/ โ โโโ prerequisites.md โ โโโ setup.md โโโ usage/ โ โโโ start.md โ โโโ features.md
โ The plugin auto-generates a menu from this.
๐ Example
mkdocs.yml
with plugin```yaml site_name: My Tech Docs theme: name: material
plugins: - search - awesome-pages
markdown_extensions: - admonition - toc: permalink: true ```
๐ Further Resources
- ๐ GitHub: mkdocs-awesome-pages-plugin
- ๐ PyPI: pypi.org/project/mkdocs-awesome-pages-plugin