Versioning¶
Every release gets its own immutable snapshot. Readers can switch versions from the header dropdown. Old URLs redirect to the latest equivalent.
Interim solution
Zensical does not yet support versioning natively. This approach bridges the gap until their versioning feature ships.
How it works¶
- Build. Zensical compiles Markdown into a static
site/folder. - Deploy. The deploy script copies
site/into a versioned directory ongh-pages. - Alias. The
latestalias always points to the current release. - Redirect. Root and deleted version URLs redirect to
latest.
gh-pages/
0.3.1/ # Immutable snapshot
0.3.2/ # Immutable snapshot
0.3.3/ # Immutable snapshot
latest/ # Copy of 0.3.3
index.html # Redirects to latest/
404.html # Redirects deleted versions
versions.json # Version selector data
Commands¶
Deploy a new version:
Or use the Python script directly:
List deployed versions:
Version selector¶
The header dropdown reads from versions.json:
[
{ "version": "0.3.3", "title": "0.3.3", "aliases": ["latest"] },
{ "version": "0.3.2", "title": "0.3.2", "aliases": [] },
{ "version": "0.3.1", "title": "0.3.1", "aliases": [] }
]
MkDocs Material displays this automatically when extra.version.provider: mike is set.
Deleted version handling¶
When a version is removed from gh-pages, its URLs return 404. The root 404.html catches these and redirects to the equivalent path under latest/.
Example: /my-life-as-a-dev/0.2.0/learning/ becomes /my-life-as-a-dev/latest/learning/.
Applying this to your project¶
Requirements¶
- GitHub Pages enabled on the
gh-pagesbranch - MkDocs Material with
extra.version.provider: mike - A static site generator that outputs to
site/
Steps¶
-
Copy the deploy script. Grab versioned_deploy.py into your project.
-
Configure MkDocs. Add to your
mkdocs.yml: -
Deploy your first version.
-
Enable GitHub Pages. Point it to the
gh-pagesbranch root.
Customization¶
Edit the repo_name variable in the 404 redirect script if your repository name differs.
When to cut a new version¶
- Breaking navigation changes
- Major content restructuring
- Stable release milestones
Avoid versioning every commit. Use latest for continuous updates and cut numbered versions for significant releases.