The versions subject handles product versioning for GitHub Docs, including Free/Pro/Team (FPT), Enterprise Cloud (GHEC), and Enterprise Server (GHES). It provides version detection, resolution, feature flags, and version-aware content rendering.
This subject is responsible for:
- Defining all available product versions (plans and releases)
- Detecting current version from URL paths
- Providing version-aware Liquid conditionals (e.g., {% if ghes %})
- Managing feature flags that vary by version
- Version resolution for content applicability
- Version picker UI component
- Deprecation banners for old versions
Related subjects:
- src/archives/ - Handles archived versions of documentation
- src/ghes-releases/ - Manages GHES release and deprecation processes
Architecture & Key Assets
Key capabilities and their locations
- lib/all-versions.ts - allVersions object: Defines all version plans (fpt, ghec, ghes) with releases
- lib/enterprise-server-releases.ts - GHES version data: supported, deprecated, latest releases
- lib/get-applicable-versions.ts - getApplicableVersions(): Determines which versions apply to content based on frontmatter
- middleware/short-versions.ts - Adds version shortcuts (e.g., ghes, fpt) to req.context
- middleware/features.ts - Loads feature flags from data/features/ and adds to context
- components/VersionPicker.tsx - UI component for switching between versions
Versions follow the format: plan@release
- FPT: free-pro-team@latest (stripped from URLs)
- GHEC: enterprise-cloud@latest
- GHES: enterprise-server@3.11, enterprise-server@3.10, etc.
Middleware adds version shortcuts to context for use in Liquid templates:
{% if fpt %}
This content only appears for Free/Pro/Team.
{% endif %}
{% if ghes %}
This content appears for all GHES versions.
{% endif %}
{% if ghes > 3.9 %}
This content appears for GHES 3.10 and later.
{% endif %}
Feature flags in data/features/*.yml control content visibility:
# data/features/my-feature.yml
versions:
fpt: '*'
ghec: '*'
ghes: '>= 3.10'
In Liquid:
{% if my-feature %}
This content only shows when my-feature is enabled.
{% endif %}
Content files specify applicable versions in frontmatter:
versions:
fpt: '*'
ghec: '*'
ghes: '>= 3.8'
npm run test -- src/versions/tests
Data & External Dependencies
- data/features/*.yml - Feature flag definitions
- lib/enterprise-server-releases.ts - GHES version data
- Content frontmatter - versions field specifies applicable versions
- URL paths - Version extracted from path (e.g., /enterprise-server@3.11/)
- req.context.currentVersion - String like enterprise-server@3.11
- req.context.currentVersionObj - Full version object with metadata
- req.context[shortName] - Boolean flags: fpt, ghec, ghes
- req.context[featureName] - Boolean flags for each feature
- req.context.allVersions - All available versions
Current State & Next Steps
Version fallback hierarchy
When no version in URL, fallback order: FPT → GHEC → GHES latest. Implemented in lib/redirects/permalinks.ts.
- Supported versions defined in enterprise-server-releases.ts
- New GHES releases added via scripts in src/ghes-releases/scripts/
- Deprecated versions archived via src/archives/
- FPT version is stripped from URLs but exists internally
- Feature flag data loaded on every request (cached per version)
- Version comparison logic only supports GHES numbered releases
- REST API versions handled separately via config in src/rest/lib/config.json
Adding a new GHES version
- Update src/versions/lib/enterprise-server-releases.ts
- Run GHES release scripts (see src/ghes-releases/scripts/)
- Update REST API config if needed
- Create release notes in data/release-notes/
Deprecating a GHES version
- Move version from supported to deprecated in enterprise-server-releases.ts
- Run archive scripts to freeze content (see src/archives/)
- Update redirects as needed