Versioned Documentation

Doks is fully prepared for versioned documentation support.

On this page

Demo

  • Available soon

Configuration

Enable

In ./config/_default/params.toml, enable Versioned Documentation:

  1. [options]
  2. ..
  3. docsVersioning = true
  4. ..

Set version

In ./config/_default/params.toml, set version:

  1. ..
  2. ## Documentation
  3. docsVersion = "1.0"
  4. ..

In ./config/_default_/config.toml, set permalink structure:

  1. [permalinks]
  2. ..
  3. docs = "/docs/1.0/:sections[1:]/:title/"

Set redirects

In ./layouts/index.redirects, set redirects:

  1. ..
  2. /docs/1.0/prologue/ /docs/1.0/prologue/introduction/
  3. /docs/1.0/help/ /docs/1.0/help/how-to-update/
  4. /docs/1.0/ /docs/1.0/prologue/introduction/
  5. /docs/ /docs/1.0/prologue/introduction/
  6. /docs/0.1/* https://v0-1-0--doks-versioning-poc.netlify.app/docs/0.1/:splat 200
  7. /docs/0.2/* https://v0-2-0--doks-versioning-poc.netlify.app/docs/0.2/:splat 200

Set menu entry

In ./config/_default/menus.en.toml, set menu entry:

  1. [[main]]
  2. name = "Docs"
  3. url = "/docs/1.0/prologue/introduction/"
  4. weight = 10

Set version switch

In ./layouts/partials/header/header.html (lines 109..123), set version switch:

  1. {{ if eq .Site.Params.options.docsVersioning true -}}
  2. <div class="dropdown ms-3">
  3. <button class="btn btn-doks-light dropdown-toggle" id="doks-versions" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static" aria-label="Toggle version menu">
  4. <span class="d-none d-lg-inline">Doks</span> v{{ .Site.Params.docsVersion }}
  5. </button>
  6. <ul class="dropdown-menu dropdown-menu-end shadow rounded border-0" aria-labelledby="doks-versions">
  7. <li><a class="dropdown-item current" aria-current="true" href="/docs/{{ .Site.Params.docsVersion }}/prologue/introduction/">Latest ({{ .Site.Params.docsVersion }}.x)</a></li>
  8. <li><hr class="dropdown-divider"></li>
  9. <li><a class="dropdown-item" href="/docs/0.2/prologue/introduction/">v0.2.x</a></li>
  10. <li><a class="dropdown-item" href="/docs/0.1/prologue/introduction/">v0.1.x</a></li>
  11. <li><hr class="dropdown-divider"></li>
  12. <li><a class="dropdown-item" href="/docs/versions/">All versions</a></li>
  13. </ul>
  14. </div>
  15. {{ end -}}

Set versions page

In ./content/en/versions.md, set draft: false.

Set branch deploys

Deploy All Branches

In Netlify, under Site Settings > Build & deploy > Branches, set Branch deploys to All.

Release process

  1. Prepare new release in local code
  2. Push changes
  3. Add new release in Github

Notes

  • When pushing changes to the master (or main) branch, the changes will be part of the next release, and already visible on the live website.
  • Use a next branch (merge when issuing the next release), when you do not want future release changes already visible on the live website.
  • Use a separate branch or repository, if you would like to be able to update previous releases.

Switch content

Version switch

Versioned Documentation Support

The version switch is part of the docs section navigation (available on all docs pages), and only shows versions known (so, no future versions) — given a specific version.

Versions page

All Versions Page

The versions page (not versioned itself, for it’s not part of the docs section) always (for all versions) shows all versions available.

Resources