Versions
A site needs versioned documentation when readers run different releases of your product at the same time and those releases differ in ways a reader acts on: commands, configuration keys, defaults. If most readers can move to the latest release, or old releases differ only in fixed bugs, keep one site and mark the exceptions in the text; a single site is easier to maintain and to search.
OINK treats each version as a separate site: its own Hugo build, usually from its own Git branch or tag, published at its own address. The theme connects those sites with a version menu in the navbar and an archive banner on the versions you no longer maintain.
The version switcher
List the versions under params.versions. When the list is not empty, a
branch icon in the navbar opens the version menu, and an icon-only menu in the
footer’s bottom bar opens upward with the same entries.
An entry shows its version, or its name when it has one. The entry whose
version equals params.version, or whose url equals the site’s baseURL
(a trailing slash aside), is marked as the current one.
An entry without a url is a gray item that cannot be clicked, which makes a
group heading, and name: '---' draws a divider (a url on a divider warns).
name accepts inline Markdown:
The same list feeds “switch version” in the command palette, so the menu and the palette always agree.
The trade-off in page-for-page links
By default a menu entry opens the target version’s home page.
version_menu_pagelinks: true appends the current page’s path to the target
URL instead, so switching version keeps the reader on the same document. The
risk is a 404: documentation structure changes between versions, and a page
added in v2.1 does not exist in v1.9. This site leaves the option off.
When most versions share a structure and one does not, turn the option on and opt that one entry out:
pagelinks: false is the only per-entry setting; an entry cannot turn page
links on when the site-wide option is off. Decide by how stable the structure
is rather than by how far apart the version numbers are: one extra click from
a version’s home page costs the reader less than a 404.
The archive banner
When you stop maintaining a version, mark its site as a snapshot so that readers arriving from a search engine know to look for something newer:
With archived_version: true, every page of the site, blog and landing pages
included, opens with a banner saying that version v1.9 is no longer actively
maintained and that this is an archived snapshot, with a link to
url_latest_version. The text comes in the site’s language, so you write none
of it. The version number in the banner is params.version; without it the
build warns and leaves the banner out, so set both. A url_latest_version
that fails the theme’s URL check warns, and the banner appears without the
link.
params.version versus params.versions
The two keys look alike but describe different things:
params.versionsis a list of sites: the versions in the menu and where each one lives.params.versionnames the version this build is. It marks the current menu entry, supplies the banner’s version number, and is the fallback when adata/download/*.yamlfile omitsversion(see Releases and downloads).
params.version is a label for readers and need not be a Git ref. When
content needs a release tag that resolves, such as the version in an install
command, declare a separate parameter for it instead of reusing
params.version. Both keys are defined in
Configuration.
Deployment layouts for multiple versions
baseURL: https://v1-9.docs.example.com/
Versions are fully independent; each needs its own DNS record and certificate.
baseURL: https://docs.example.com/v1.9/
One domain collects all search ranking; the host must route each path to a different build.
Build each version on its own: check out its branch or tag, build with that
version’s hugo.yml, and publish to its address. Because the menu is part of
each build, adding a version means updating params.versions on every branch
you still publish and rebuilding those sites; an old site that is not rebuilt
keeps its old menu. Archived sites carry the same list plus
archived_version: true.
baseURL must include the path segmentOtherwise the search index, page actions and asset links all point at the domain root. The page looks correct, but search returns nothing, which makes this the most common subpath failure. See Deploy for the rest of the host setup.
Verify
Run these from your site’s root after a production build. Replace
public/docs/getting-started/index.html with a documentation page your site
actually generates, including the language prefix if it has one.
-
Confirm that the version menu reached the page:
With
params.versionsempty or unset there is no menu at all. -
Check that the current version is marked:
No result means that no entry’s
versionequalsparams.versionand no entry’surlequalsbaseURL. -
Follow each menu link. With
version_menu_pagelinkson, switch from a page that an older version lacks and check that the reader lands somewhere acceptable. -
On an archived site, open any page and check that the banner is at the top, in the site’s language, with a working link to the current version.
-
Press ⌘/Ctrl + K and check that “switch version” lists the same versions as the menu.
Related
- Navigation and menus — where the version menu sits in the navbar and footer
- Command palette — “switch version” in the palette
- Deploy —
baseURL, subpaths and multi-target publishing - Releases and downloads — download data falling back to
params.version - Configuration — full definitions of
version/versions/archived_version