Versioning

Customization•4 min read|
|

DocsLit supports multi-version documentation using git branches. Each version maps to a branch, and readers can switch between versions using a dropdown in the site header.

How it works

DocsLit's versioning is branch-based. Each version of your documentation lives on a separate git branch. When you build the site, DocsLit checks out each branch and builds the pages for that version.

graph LR A[main branch] -->|"Latest (0.3)"| B[Build v0.3] C[v0.2 branch] -->|"Previous"| D[Build v0.2] B --> E[dist/] D --> E

Configuration

Add a versions object to your docslit.json:

{ "name": "My Product", "versions": { "default": "0.3", "list": [ { "version": "0.3", "branch": "main", "tag": "Latest" }, { "version": "0.1", "branch": "v0.1", "tag": "Previous" } ] }, "sidebar": [...] } The version shown by default when a reader visits your site. An array of version objects, each specifying a version number, git branch, and display tag. The version identifier (e.g., 0.2, 1.0, 2.0). The git branch containing the docs for this version. A display label shown in the version dropdown (e.g., Latest, Beta, LTS).
Develop on main

Write and update documentation on the main branch. This always represents the latest version.

Cut a version branch on release

When you release a new version of your product, create a branch from main:

git checkout -b v0.3 git push origin v0.3
Update the config

On main, update docslit.json to add the new frozen version and point main to the next version:

{ "versions": { "default": "0.3", "list": [ { "version": "0.3", "branch": "main", "tag": "Latest" }, { "version": "0.2", "branch": "v0.2", "tag": "Previous" }, { "version": "0.1", "branch": "v0.1" } ] } }
Build

Run docslit build. DocsLit checks out each branch and builds only the pages that changed between versions.

Patch releases (0.1.5 to 0.1.6) rarely change documentation. Cut version branches on minor or major releases to avoid unnecessary maintenance overhead.

Build output

Versioned builds produce a directory structure with each version in its own folder:

The root index.html redirects to the first page of the default version, and each version's index.html redirects to that version's first page. Each carries a canonical link to its target, and basePath is applied to these redirects and to the version switcher. Only pages that differ between versions are rebuilt — unchanged pages are shared to keep build times fast.

Version-specific content

Use wc-versions to show different content depending on the selected version. See data display for details.

You can also set a per-version announcement banner in versions.list to show maintenance notices or release-specific messages.