Managing Multiple Documentation Versions with GitBook Branches
Learn how to use Git branches and individual book.json files to host multiple documentation versions in GitBook, with a concrete setup example, build instructions, and notes on build time and plugin compatibility.
04 Dec 2025, 07:44 UTC

Problem: Keeping docs in sync across product releases
When a software project maintains several active releases (for example, a latest main line and a stable 1.x line), the documentation often needs to reflect the same split. Copying files manually or maintaining separate repositories leads to drift, duplicated effort, and missed updates.
Thesis: Use Git branches and per‑branch book.json to host independent documentation sets
GitBook resolves content paths relative to the repository root, so any Markdown file can be included without extra configuration. By creating a dedicated branch for each version and letting each branch carry its own book.json, you get isolated builds while sharing the same Git remote.
Setting up versioned branches
- Start from a clean repository that already contains your Markdown content and a base
book.json. - Create a branch for the version you want to document:
# Run in your local clone
git checkout -b 1.x main
Switch to the new branch and adjust book.json to reflect the version‑specific navigation, theme, or plugins. For instance, you might change the title field or add a plugin that is only needed for the 1.x release.
# Example book.json on the 1.x branch
{
"title": "My Project 1.x Documentation",
"description": "Documentation for the 1.x release series",
"plugins": ["highlight", "search"],
"structure": {
"README.md": "Introduction",
"chapter1/README.md": "Getting Started"
}
}
Commit the changes and push the branch:
git add book.json
git commit -m "Add version‑specific book.json for 1.x"
git push -u origin 1.x
Building and previewing locally
With the branch checked out, the GitBook CLI reads the local book.json and builds the site:
gitbook serve
The command starts a local server (default http://localhost:4000) and regenerates the output whenever you edit a Markdown file or book.json. To produce a static export for CI or deployment, run:
gitbook build
The generated files appear in the _book directory. You can verify that the navigation matches the structure section of book.json by opening _book/index.html in a browser and checking the sidebar.
Trade‑offs and limitations
- Build time grows with the number of pages and with client‑side search indexing (Lunr.js). For very large documentation sets, consider disabling the
searchplugin during frequent preview builds. - Custom plugins must match the installed GitBook CLI version. A version mismatch can cause silent failures or missing features, so run
gitbook --versionbefore production builds and keep yourpackage.jsonor CLI installation in sync. - Each branch maintains its own copy of shared assets (images, stylesheets). If you need to reuse identical assets across versions, store them in a common directory and reference them with relative paths from the repository root.
Actionable next steps
- Audit your current documentation layout and decide which product lines need separate versioned sets.
- Create a branch for each version, add a tailored
book.json, and push to the remote. - Integrate
gitbook buildinto your CI pipeline to publish the_bookfolder as static assets for each branch. - Monitor build times; if they become prohibitive, toggle the search plugin or split large guides into separate books.
By leveraging Git’s branching model and GitBook’s per‑branch configuration, you maintain clear, version‑specific documentation without duplicating effort or risking inconsistencies between releases.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.