Skip to content

Documentation versions

Enable versioning in docskit.config.ts:

TypeScript
versioning: {
  currentLabel: "Next (unreleased)",
  defaultVersion: "latest",
},

Keep editing content/ for the next release. Production serves the latest published snapshot at the default documentation URLs. Before the first publication, those URLs show Next. Set defaultVersion: "next" to keep Next at the default URLs instead; the latest release then uses its versioned URL.

A version selector appears above the guide and API sidebar navigation. On smaller screens, open the documentation navigation to switch versions. Pending snapshots are hidden. Next displays an unreleased notice, older releases link to latest stable, and latest stable has no archive notice.

Documentation lines

The selector groups stable package releases by compatibility line:

Package releaseDocumentation entryEffect
0.0.00.0Creates the first line
0.0.10.0Updates the same entry
0.1.00.1Adds a new entry
0.1.20.1Updates the same entry
1.0.01Adds a new entry
1.4.21Updates the same entry
2.0.02Adds a new entry

Before 1.0, a minor release starts a new docs line. From 1.0 onward, only a major release starts a new line. The most recently promoted release in a line supplies its content, navigation, and API pages. The stable entry is labeled, for example, 0.1 (latest) or 1 (latest). Next stays separate.

Release snapshots retain full IDs such as v0.1.2 internally. Published files remain immutable; promoting a patch selects its snapshot for the existing line. Pending releases never replace that line's published content. Prerelease and custom IDs keep their full labels instead of joining a stable line.

Snapshot and publish

Run commands from the directory containing docskit.config.ts:

Shell
pnpm exec docskit version v1.0.0

This copies content and navigation into an immutable, pending snapshot:

Plain text
content/                   # Next, edited continuously
versions/
  versions.json            # Explicit publication state
  v1.0.0/
    content/
    navigation.json

Commit the snapshot with your release. Once that release is published, promote it:

Shell
pnpm exec docskit promote v1.0.0

Promotion records the snapshot as published and sets the stable pointer. It does not publish a package or deploy your site. Commit the manifest and rebuild. This repository's release workflow performs promotion after successful npm publication.

JSON
{
  "latest": "v1.0.0",
  "versions": [
    { "id": "v1.1.0", "status": "pending" },
    { "id": "v1.0.0", "status": "published" }
  ]
}

latest must reference a published snapshot, or be null before the first release. Legacy array manifests are read as pending snapshots: promote released versions explicitly rather than inferring publication from a directory name.

Snapshots cannot be overwritten. IDs accept 1–64 lowercase letters, digits, dots, underscores, or hyphens, starting with a letter or digit. Stable archive URLs use the documentation line: v0.1.2 uses /v/0.1/, and v1.4.2 uses /v/1/. A leading v is omitted from numeric labels. IDs that identify the same release, such as v1.0.0 and 1.0.0, are rejected.

Production routes

PageLatest stableNextOlder line 0.9
Guide overview/docs//next/docs//v/0.9/docs/
Installation/docs/installation//next/docs/installation//v/0.9/docs/installation/
API overview/api-references//next/api-references//v/0.9/api-references/

The deployment base path prefixes every route. Switching versions preserves the page, query, and fragment when the destination contains that page; otherwise it opens that version's guide overview. Each version has its own search index and canonical URLs. When Next also occupies the default URLs, documentation canonicals point to /next/.

Snapshots save the guide sidebar, API sidebar, and navbar links. Branding, public assets, styles, and custom Markdown components come from the current project. Keep shared components compatible with archived Markdown. The homepage remains shared, and the logo always links back to it. Social images use the shared image.

public/v/ and public/next/ are reserved while versioning is enabled.

Develop and build

Shell
pnpm exec docskit dev
pnpm exec docskit check
pnpm exec docskit build
pnpm exec docskit preview

Development opens Next at the default URLs with live updates. Published releases are available at /v/<line>/; their previews and the /next/ preview are built at startup. Use the default development URLs while editing. Restart after changing snapshots, publication state, version settings, or shared branding for previews.

Production builds the default site, Next, and published releases into one static dist/. Preview uses these production routes. Pending snapshots are validated but never included in output. Only the selected snapshot for each published line adds a site build. Superseded patch snapshots remain on disk for release verification and rollback.

To remove a docs line, remove all its release entries and directories, then rebuild. Removing just its selected snapshot makes the next published snapshot in that line available. If removing latest stable, point latest at another published snapshot or null. Set versioning: false to build only content/ at the default URLs while keeping committed snapshots.

Include generated API pages

Run your API generator for the release before docskit version <id>. The snapshot copies content/api-references/ and the API navigation with the guides. Later generator runs update Next without changing the snapshot. See API documentation for output requirements.

This repository's pnpm docs:snapshot command generates the numeric release API and creates a pending snapshot for the package version. Repository automation is covered in the contributor guide.