On this page
Versions
When a release changes how your project works, readers of older releases still need the old docs. Clay keeps older versions of the docs online next to the latest ones, each with its own navigation, search and URLs.
#How versions work
Most projects never need versions. Their pages are right in docs/, and Clay shows no version switcher.
With versions, each version has a folder of its own inside docs/:
my-project
- clay.yamlversion: "3.x" names the latest
docs
latestthe latest docs, at /
- index.md
- guides
- 2.xat /2.x
- 1.xat /1.x
docs/latest/is always the latest version. It lives at the root of the site:/guides/setup.- Every other folder in
docs/is an older version, a copy ofdocs/latest/saved when that version was current.docs/1.x/lives under/1.x:/1.x/guides/setup. - All versions sit at the same depth, so a path that leads out of the docs, like an include of
../../../clay.yaml, works the same in each copy.
This site works this way: its pages are in docs/latest/, the docs of Clay 4 in docs/4.x/ and those of Clay 3 in docs/3.x/, online at /4.x and /3.x.
#Saving a version
Save the latest docs, right before the release changes them:
This copies
docs/latest/todocs/2.x/. Inclay edit, V does the same and switches the editor to the new version.A saved version keeps today’s text: in the copy, Clay fills in the variables and writes out includes of files outside
docs/latest/, likeconfig/ordocs/_snippets/. When the latest docs move on to a new version number, the old ones keep theirs.Label the latest docs in
clay.yaml. Withoutversion, the switcher calls them “Latest”.clay.yamlversion: "3.x"Update
docs/latest/for the new release, commit and release. The old docs are online at/2.xfrom the first build.
Version names become part of URLs, so they may contain letters, digits, ., - and _. latest, docs, _clay and _nuxt are reserved.
#The first version
While the pages are right in docs/, the first clay version moves them into docs/latest/ before it saves the copy. It shows what it is about to do and asks first:
- Paths that lead out of
docs/get one more../: includes, links, images and files in HTML. Paths within the docs move along and stay as they are. faviconandnavbar.logoinclay.yamlfollow when they point intodocs/.- Commands and lists that name paths in
docs/, likegenerateinclay.yaml,.gitignoreor the scripts inpackage.json, are listed for you to check: only you know whether they mean the latest docs. - Dates stay: Clay reads “last updated” from git, which sees the move as a rename.
In scripts and CI, where nobody can answer, add --yes. Without it, nothing changes.
Tip
Folders in docs/ that start with _ are no versions. Snippets that every version shares can live in docs/_snippets/.
#The version switcher
As soon as there is an older version, the navbar shows a version switcher, newest first. Switching keeps the page you are reading when the other version has it, and otherwise opens that version’s start page. It keeps the language too.
Pages of older versions show a banner that says which version they belong to and links to the same page in the latest version.
#What each version has of its own
| Per version | |
|---|---|
| Pages, images and files | docs/<name>/ |
| Start page, folder titles, icons and order | The version’s index.md files |
| Search index | Results stay within the version |
| Edit links | Lead into docs/<name>/, when editURL ends in docs/ |
| Translations | *.de.md files inside the version’s folder |
| Redirects | Stay within the version |
clay.yaml is shared: all versions have the same title and navbar.
#Editing older versions
Older versions are plain files: fix a typo in docs/1.x/ like anywhere else, or switch clay edit to the version with v. Links inside an older version stay in that version, as long as they are relative: [Setup](setup.md) links to /1.x/setup. Links starting with / lead to the latest version.
Note
Each saved version adds its pages to the build. Keep the versions your users actually run, and delete the folders of versions nobody uses anymore.