|
| 1 | +--- |
| 2 | +title: Support versions with products |
| 3 | +description: Adding API versioning to products in your Fern documentation |
| 4 | +--- |
| 5 | + |
| 6 | +# Versioning Your Products |
| 7 | + |
| 8 | +You can add version support to products in your documentation by configuring versions in your `docs.yml` file. Each product can have multiple versions, making it easy for users to navigate between different API versions. |
| 9 | + |
| 10 | +## Add Versions to Products |
| 11 | + |
| 12 | +Add a `versions` array to each product in your `docs.yml` file: |
| 13 | + |
| 14 | +```yaml |
| 15 | +products: |
| 16 | + - display-name: Data API |
| 17 | + path: ./products/data/versions/v2.yml |
| 18 | + subtitle: Integrate with our data platform |
| 19 | + icon: fa-light fa-database |
| 20 | + image: ./assets/product-selector/data-api-image.svg |
| 21 | + slug: data |
| 22 | + versions: |
| 23 | + - display-name: v2 |
| 24 | + slug: v2.0.0 |
| 25 | + path: ./products/data/versions/v2.yml |
| 26 | + - display-name: v2 (beta) |
| 27 | + slug: v2.0.0-beta |
| 28 | + path: ./products/data/versions/v2-beta.yml |
| 29 | + - display-name: v1 (legacy) |
| 30 | + slug: v1.0.0 |
| 31 | + path: ./products/data/versions/v1.yml |
| 32 | +``` |
| 33 | +
|
| 34 | +Each version requires: |
| 35 | +- `display-name`: The name shown in the version selector |
| 36 | +- `slug`: A URL-friendly identifier for the version |
| 37 | +- `path`: Path to the version's documentation files |
| 38 | + |
| 39 | +## Version Organization |
| 40 | + |
| 41 | +Best practices for organizing versioned documentation: |
| 42 | + |
| 43 | +1. Create a `versions` directory for each product |
| 44 | +2. Store each version's documentation in a separate YAML file |
| 45 | +3. Name files consistently (e.g., `v1.yml`, `v2.yml`) |
| 46 | +4. Use clear version labels that indicate status (e.g., "beta", "legacy") |
| 47 | + |
| 48 | +## Example Structure |
| 49 | + |
| 50 | +``` |
| 51 | +docs/ |
| 52 | +├── products/ |
| 53 | +│ └── data/ |
| 54 | +│ └── versions/ |
| 55 | +│ ├── v1.yml |
| 56 | +│ ├── v2.yml |
| 57 | +│ └── v2-beta.yml |
| 58 | +└── docs.yml |
| 59 | +``` |
| 60 | +
|
| 61 | +The version selector will automatically appear in your documentation when versions are configured, allowing users to easily switch between different API versions. |
0 commit comments