Skip to content

Versions

Publish documentation for several product versions side by side, with a version switcher and a banner that marks unmaintained versions as archives.

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 v1.8.0 connects independently built sites with a version menu. The upcoming v1.9 also supports publishing several versions in one Hugo build. Choose a native build when releases share source files and readers need to switch versions on the page they are reading.

Publish several versions in one build

The key under versions supplies both the menu label and the URL prefix of an archived edition. Use v4.1 for a manual that covers the whole minor series. Installation commands can still specify an exact tag such as v4.1.2. When a download has no explicit version or tag, the edition v4.1 gives both ${version} and ${tag} the value v4.1. Use manual-${tag}.zip for an asset named manual-v4.1.zip.

The following configuration publishes two manuals. Put shared English and Chinese pages in manual/v4/docs/, for example install.md and install.zh.md. Put files introduced or changed in v4.2 at the same paths beneath manual/v4.2/. Hugo picks the first matching mount. Keep the blog in content/blog/ so only the default version publishes it, and set version_shared: true in content/blog/_index.md so links from older manuals know that /blog/ is intentionally shared across releases.

hugo.yml
defaultContentLanguage: en
defaultContentVersion: v4.2
languages:
  en: {weight: 1}
  zh: {weight: 2}
versions:
  v4.2: {weight: 1}
  v4.1: {weight: 2}
module:
  imports:
    - path: github.com/pgsty/oink
  mounts:
    - {source: manual/v4.2, target: content, sites: {matrix: {versions: [v4.2]}}}
    - {source: manual/v4, target: content, sites: {matrix: {versions: ['v4.*']}}}
    - {source: content, target: content, sites: {matrix: {versions: [v4.2]}}}
params:
  version_home: /docs
  links: {missing: warn}
  ui:
    version_link: true
cascade:
  - target: {sites: {matrix: {versions: [v4.1]}}}
    params: {version_status: archived}

Write [Install](/docs/install/) in both languages. On the older Chinese site it opens /v4.1/zh/docs/install/. An explicit language such as /en/docs/install/ keeps the version. An explicit version such as /v4.2/docs/install/ keeps the language. You can specify both prefixes in either order. With separate domains for each language, a language switch points to the corresponding host.

Because content/blog/_index.md sets version_shared: true, a link to /blog/ in the older manual opens the default version’s blog in the same language; an unshared manual chapter added in v4.2 and missing from v4.1 is reported as an unresolved site link instead of silently opening v4.2 commands. An explicit version binds the link to that release. If the target is missing, the build names the content file that holds the link and keeps the authored address. Set params.links.missing to error for a failing build or ignore for silent output. With params.ui.version_link: true, the page-action menu and command palette add Copy version link (/v4.2/docs/install/) on versioned manual pages while omitting it on version_shared sections. When defaultContentVersionInSubdir is false, back the current release’s /v4.2/docs/* paths with temporary 302 redirects (scoped to manual paths, never /*, while frozen patch aliases such as /v4.1.0/* -> /v4.1/:splat use 301) so tickets pasted today resolve to /docs/* now and directly to /v4.2/docs/* once v4.3 becomes the default. A link to an alias keeps the alias address in the reader’s version, and that version’s redirect leads on. With disableAliases: true, configure the redirect on your host. A relative URL such as ../install/, a Print address such as /_print/book/ and a Markdown output such as /docs/install/index.md also stay in that version. Use relative .md paths for source pages. To link a Markdown download in static/, start at the site root, for example /downloads/guide.md. The published-output check below verifies that file exists. A directory served from static/ still reports a missing page. Markdown exports use the same destinations and preserve local fragments and code examples.

The navbar, footer and command palette switch to the matching page, or to the target version’s home when that page is absent. With params.ui.compare: true, pressing V opens Duo View side by side with another native version of the same page (including linked version and language menus). Each version searches its own pages. With version_home: /docs, opening an older home takes the reader to its local documentation root. Omit the setting to keep the Landing page. Older pages show a link to the latest version and consolidate their <link rel="canonical"> to the matching page in the default version (falling back to the newest intermediate version or self when a page was removed in newer releases, and staying out of the older version’s sitemap.xml and hreflang links whenever canonicalized forward). Mark a release or a section with version_status: archived to show the archive notice, and add noindex: true to its cascade if you want search engines to drop that release completely instead of consolidating signals. When a project also defines Spaces (roles), params.versions entries accept a roles allowlist.

You can append a separately hosted archive under params.versions. If its URL is /manual/classic/, a link to /manual/classic/install/ opens the archive even when the current manual has an installation page at the same content path. Use a relative .md source link to reach the local page in the same directory. A full URL such as https://docs.example.org/status/ always opens the address you specify. The version_menu_pagelinks setting controls the archive’s menu entry. To omit taxonomy pages from an old release, add a cascade entry with target: {kind: '{taxonomy,term}', sites: {matrix: {versions: ['v3.*']}}} and build: {render: never, list: never}.

Add independently built versions to the menu

List the independently hosted 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.

hugo.yml
params:
  # the version this site is
  version: v2.1
  # the menu's accessible name and tooltip (default: Version)
  version_menu: v2.1
  versions:
    - version: v2.1
      url: https://docs.example.com
    - version: v2.0
      url: https://v2-0.docs.example.com
    - version: v1.9
      url: https://v1-9.docs.example.com

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:

hugo.yml
params:
  versions:
    - name: '**Current**'
    - version: v2.1
      url: https://docs.example.com
    - name: '---'
    - name: '**Older versions**'
    - version: v1.9
      url: https://v1-9.docs.example.com

The same list feeds “switch version” in the command palette, so the menu and the palette always agree.

By default an external archive 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:

hugo.yml
params:
  version_menu_pagelinks: true
  versions:
    - version: v2.1
      url: https://docs.example.com
    - version: v1.9
      url: https://v1-9.docs.example.com
      pagelinks: false # restructured since; go to its home page

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 an independently built version, mark its site as a snapshot so that readers arriving from a search engine know to look for something newer:

hugo.yml
params:
  archived_version: true
  version: v1.9
  url_latest_version: https://docs.example.com

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. Add params.ui.noindex: true when an independently built archive should also stay out of search engines (noindex, follow and an empty sitemap.xml). 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

An independently built site uses these two settings. A native matrix gets the current version from Hugo for its menu, banner and download records.

  • params.versions is a list of sites: the versions in the menu and where each one lives.
  • params.version names the version this build is. It marks the current menu entry, supplies the banner’s version number, and is the fallback when a data/download/*.yaml file omits version (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.

Deploy independently built versions

Subdomain

baseURL: https://v1-9.docs.example.com/

Versions are fully independent; each needs its own DNS record and certificate.

Subpath

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.

On a subpath deployment, baseURL must include the path segment

Otherwise 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

From the site root, scan the published HTML and the page actions in its command manifest. Pass your deployment URL, including any path prefix. With no --version, the scanner includes the default edition and recognizes other editions by their Hugo site outputs. Repeat the option to select particular editions, or use --version editor/v4.1 to select one role. For separate language domains, run it once per publish directory and URL. It checks edition boundaries, local page and machine-output links, and the published files behind shared Markdown, HTML and XML links. It also checks the generated entries in llms.txt. Within each llms-full.txt, it compares records with their page Markdown up to the first HTML-only source. An explicitly host-qualified service or a separately deployed archive can live outside the build.

python3 ../oink/bin/check-version-links.py --public public --base-url https://docs.example.com/

For independently built sites, check the menu 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.

  1. Confirm that the version menu reached the page:

    hugo --printPathWarnings
    PAGE=public/docs/getting-started/index.html
    test -f "$PAGE" && grep -c 'nav-version-menu' "$PAGE"

    A single-version build shows this menu when params.versions contains entries.

  2. Check that the current version is marked:

    grep -o 'td-nav-hover-menu__option td-is-active[^>]*' "$PAGE"

    No result means that no entry’s version equals params.version and no entry’s url equals baseURL.

  3. Follow each menu link. With version_menu_pagelinks on, switch from a page that an older version lacks and check that the reader lands somewhere acceptable.

  4. 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.

  5. Press ⌘/Ctrl + K and check that “switch version” lists the same versions as the menu.