# Doc versioning mechanism

**URL:** https://discourse.cmake.org/t/doc-versioning-mechanism/4814
**Category:** Development
**Created:** [January 11, 2022, 8:18am UTC](https://discourse.cmake.org/t/doc-versioning-mechanism/4814 "2022-01-11T08:18:21Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [January 11, 2022, 2:28pm UTC](https://discourse.cmake.org/t/doc-versioning-mechanism/4814/3 "2022-01-11T14:28:44Z")

</div>

We configure sphinx with a custom template directory [here](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.22.1/Utilities/Sphinx/conf.py.in#L29). That directory contains a custom layout template, which has [special version switch code](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.22.1/Utilities/Sphinx/templates/layout.html#L20-25) activated by passing `-A versionswitch=1` when [running sphinx](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.22.1/.gitlab/os-linux.yml#L492). The version switch code loads `version_switch.js`, which we publish on the web host [here](https://cmake.org/cmake/help/version_switch.js).

The addition of the “This documents an old version of” and “Click here to see the latest release” is done by internal infrastructure we use to prepare the documentation for publication on `cmake.org`. Basically it updates that same `layout.html` template:

```auto
{%- block relbar1 %}
{{ super() }}
{% if outdated is defined %}
    <div class="outdated">
      This documents an old version of CMake.
      <a href="https://cmake.org/cmake/help/latest/{{ pagename }}.html">
        Click here to see the latest release.
      </a>
      <span class="version_switch_note"></span>
    </div>
{% endif %}
{% endblock %}

```

Then all the versions except the latest are built with the sphinx `-A outdated=1` flag.

---

_[View the full topic](https://discourse.cmake.org/t/doc-versioning-mechanism/4814)._
