These notes cover the local setup and maintenance for the MkDocs + Mike versioning system.
Ensure you have Python 3 installed. It is recommended to use a virtual environment.
# Install core documentation stack
pip install -r requirements.txtRun these once to prepare the gh-pages branch for the GitHub Action.
# 1. Ensure you have the gh-pages branch locally
git fetch origin gh-pages --depth=1
# 2. Create the root redirect (Receptionist)
# This points [https://digilive.github.io/mushroom-strategy/](https://digilive.github.io/mushroom-strategy/) to /latest/
mike set-default --push latestUse this for writing. No version selector, but very fast:
mkdocs serveUse this to test the version selector:
# Deploy your current branch to a local-only version name
mike deploy main-local
# Serve the versioned site
mike serveAccess at: http://127.0.0.1:8000/main-local/
| Scenario | Command / Solution |
|---|---|
| Remove a ghost version | mike delete <version_name> |
| List all current versions | mike list |
| Sync local gh-pages | git checkout gh-pages && git pull origin gh-pages |
| Selector is missing | Ensure mkdocs.yml has extra: version: provider: mike |
| Update "latest" alias | mike alias <version_number> latest |
| Set the default landing | mike set-default latest |
- Never manually deploy a Release: Let the GitHub Release Action handle numbered versions (v1.x.x).
- Never manually deploy to 'main': Let the "Push to Main" Action handle the development version.
- Branch Protection: Avoid manual commits to the gh-pages branch.
If the versions.json gets corrupted, fix it locally on the gh-pages branch and push.
Ensure this block remains in your config to enable the UI integration:
extra:
version:
provider: mikeTo stay within the Node.js ecosystem, these scripts can be added to your package.json.
This ensures you don't need to remember the specific mike or mkdocs commands:
{
"...": "...",
"scripts": {
"docs:serve": "mkdocs serve",
"docs:serve-versioned": "mike serve",
"docs:list": "mike list",
"...": "..."
}
}If the version selector disappears from the site, the versions.json file is likely missing from the root of the
gh-pages branch.
You don't need to manually write the JSON. You can force mike to recreate it by "re-aliasing" your existing versions:
-
Sync your local gh-pages:
git checkout gh-pages git pull origin gh-pages
-
Re-generate the JSON:
mike alias main main mike alias <your-latest-tag> latest
-
Verify and Push: Check that versions.json exists in your folder, then:
git add versions.json git commit -m "fix: restore versions.json" git push origin gh-pages
The versions.json file lives only on the gh-pages branch. It tells the UI which versions exist and which aliases
(like latest) point where.
- If a version isn't in this file, it won't show in the dropdown.
- If this file is missing, the version selector disappears.
[
{
"version": "main",
"title": "main",
"aliases": []
},
{
"version": "v1.0.0",
"title": "v1.0.0",
"aliases": ["latest"]
}
]When running documentation tools locally, a site/ directory may be created.
-
mkdocs serve: Does not usually create a physicalsite/folder; it serves the site from memory. -
mkdocs build: Generates a static version of the current docs intosite/. -
mike deploy: Bypasses the standardsite/folder logic. It renders the site and commits it directly to a temporary area before pushing to thegh-pagesbranch.
The site/ folder must never be committed to the main branch.
It contains generated assets that will cause merge conflicts and bloat the repository.
-
Ensure
.gitignoreincludessite/: Verify your.gitignoreat the project root has a line for/site/. -
Cleaning up: If you accidentally run a manual build and want to clean your workspace: Delete the
site/folder.