You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,132 +4,111 @@ description: 'Build separate versions'
4
4
icon: 'square-chevron-down'
5
5
---
6
6
7
+
These guides will assume `v1` pages are in a folder named `v1`, `v2` pages are in a folder named `v2`, and so on. While this method of structuring your files isn't strictly necessary, it's a great way to keep your files organized.
8
+
7
9
## Setup
8
10
9
-
Add `"versions": ["v2", "v1"]` to your `mint.json` file where "v1" and "v2" are the names of your versions. You can put any number of versions in this array. The first version from the array serves as the default version.
11
+
Add `"versions": ["v2", "v1"]` to your `mint.json` file where `v1` and `v2` are the names of your versions. You can put any number of versions in this array. The first version from the array serves as the default version.
10
12
11
13
<Tip>
12
14
The versions dropdown will show your versions in the order you include them in
13
15
`mint.json`.
14
16
</Tip>
15
17
16
-
## Versioning Options
17
-
18
-
You can add version values to anchors, groups, or individual pages.
19
-
20
-
### Anchors
21
-
22
-
You can hide an entire anchor based on a version. This is useful when you have dozens of pages you want to hide. For example, for an API reference section.
23
-
24
-
In `mint.json`, simply add `version` to your anchor. Anchors without a version value are shown in every version.
25
-
26
-
```json
27
-
"anchors": [
28
-
{
29
-
"name": "API Reference V1",
30
-
"url": "v1/api-reference",
31
-
"version": "v1"
32
-
},
33
-
{
34
-
"name": "API Reference V2",
35
-
"url": "v2/api-reference",
36
-
"version": "v2"
37
-
},
38
-
{
39
-
"name": "Anchor Without a Version",
40
-
"url": "example-anchor"
41
-
}
42
-
]
43
-
```
44
-
45
-
You don't need to add `v1/` or `v2/` to the start of your URLs, but some customers do it to keep their doc files organized.
46
-
47
-
### Tabs
48
-
49
-
Similarly, you can version with tabs. In the `mint.json`, add `version` to the tab. Tabs without a version value are shown in every version.
18
+
## Versioning Groups and Pages
50
19
51
-
```json
52
-
"tabs": [
53
-
{
54
-
"name": "API Reference V1",
55
-
"url": "v1/api-reference",
56
-
"version": "v1"
57
-
},
58
-
{
59
-
"name": "API Reference V2",
60
-
"url": "v2/api-reference",
61
-
"version": "v2"
62
-
},
63
-
{
64
-
"name": "Tabs Without a Version",
65
-
"url": "example-tab"
66
-
}
67
-
]
68
-
```
20
+
The best way to specify page versions is by adding a version value to a group in the navigation. When you specify the version of a group, that version is applied to all pages within that group.
69
21
22
+
You can also specify the version of a single page in the page metadata. Versions on individual pages always take precedence.
70
23
71
-
### Groups
72
-
73
-
You can version specific groups. This is useful when a few pages changed but everything else stayed the same.
74
-
75
-
Simply add `version` to your groups. Groups without a version value are shown in every version.
76
-
77
-
In the example below, pages in `Nested Group V1` only show up when `v1` docs are shown.
You can version a single page. Add `version` to the top of your page metadata like so:
102
-
103
-
```md
35
+
```yaml Pages (quickstart.mdx)
104
36
---
105
-
title: 'My page title'
106
-
description: 'My page description'
107
-
version: 'v1'
37
+
title: 'Quickstart'
38
+
version: 'v2'
108
39
---
109
40
```
41
+
</CodeGroup>
42
+
43
+
<Warning>
44
+
While it is possible to nest versioned groups within versioned groups, it is not recommended. If you do take this approach, the more deeply-nested version takes precedence.
45
+
</Warning>
46
+
47
+
### Versioning Tabs and Anchors
48
+
49
+
You can hide a tab or anchor based on a version. This is useful if you have links that are only relevant in one version. Importantly, this does **not** apply the version to the pages within that anchor.
50
+
51
+
In `mint.json`, simply add `version` to your tab or anchor. Tabs and anchors without a specified version are shown in every version.
52
+
53
+
<CodeGroup>
54
+
```json Tabs
55
+
"tabs": [
56
+
{
57
+
"name": "API Reference V1",
58
+
"url": "v1/api-reference",
59
+
"version": "v1"
60
+
},
61
+
{
62
+
"name": "API Reference V2",
63
+
"url": "v2/api-reference",
64
+
"version": "v2"
65
+
},
66
+
{
67
+
"name": "Migrating from V1 to V2",
68
+
"url": "https://mintlify.com/changelog/v2"
69
+
},
70
+
],
71
+
```
110
72
111
-
Your navigation config in `mint.json` should include the page like normal, but the page will only show up when the correct version is selected.
73
+
```json Anchors
74
+
"anchors": [
75
+
{
76
+
"name": "API Reference V1",
77
+
"url": "v1/api-reference",
78
+
"version": "v1"
79
+
},
80
+
{
81
+
"name": "API Reference V2",
82
+
"url": "v2/api-reference",
83
+
"version": "v2"
84
+
},
85
+
{
86
+
"name": "Migrating from V1 to V2",
87
+
"url": "https://mintlify.com/changelog/v2",
88
+
"version": "v2"
89
+
},
90
+
],
91
+
```
92
+
</CodeGroup>
112
93
113
-
### Reusable Pages
94
+
### Sharing Between Versions
114
95
115
-
Not _all_ content has to be hidden though! Any content without a version value shows up in every version so you never duplicate content!
96
+
Not _all_ content has to be hidden though! Any content without a specified version appears in every version so you don't have to duplicate content!
116
97
117
98
## Troubleshooting
118
99
119
100
Common errors and how to fix them
120
101
121
102
<AccordionGroup>
122
-
<Accordiontitle="Pages Show Up In Wrong Version"icon="circle-exclamation">
123
-
You likely nested a version inside of another. For example, your group had version "v1" but your page had version "v2".
124
-
125
-
We do not recommend nesting versions inside of each other because it's hard to maintain your docs later.
126
-
127
-
</Accordion>
103
+
<Accordiontitle="Pages Show Up In Wrong Version"icon="circle-exclamation">
104
+
You likely nested a version inside of another. For example, your group had version "v1" but your page had version "v2".
0 commit comments