@@ -55,6 +55,20 @@ Check out the versioning example to see it in action –
55
55
[version example] : https://squidfunk.github.io/mkdocs-material-example-versioning/
56
56
[Why use mike?] : https://github.com/jimporter/mike#why-use-mike
57
57
58
+ # ## Stay on the same page when switching versions
59
+
60
+ When the user chooses a version in the version selector, they usually want to go
61
+ to the page corresponding to the page they were previously viewing. Material for
62
+ MkDocs implements this behavior by default, but there are a few caveats :
63
+
64
+ - the [`site_url`] must be set correctly in `mkdocs.yml`. See the ["Publishing a
65
+ new version"](#publishing-a-new-version) section for an example.
66
+ - you must be viewing the site at that URL (and not locally, for example).
67
+ - the redirect happens via JavaScript and there is no way to know which page you
68
+ will be redirected to ahead of time.
69
+
70
+ [`site_url`] : https://www.mkdocs.org/user-guide/configuration/#site_url
71
+
58
72
# ## Version warning
59
73
60
74
<!-- md:version 8.0.0 -->
@@ -133,7 +147,13 @@ mike deploy --push --update-aliases 0.1 latest
133
147
` ` `
134
148
135
149
Note that every version will be deployed as a subdirectory of your `site_url`,
136
- e.g. :
150
+ which you should set explicitly. For example, if your `mkdocs.yml` contains :
151
+
152
+ ` ` ` yaml
153
+ site_url: 'https://docs.example.com/' # Trailing slash is recommended
154
+ ` ` `
155
+
156
+ the documentation will be published to URLs such as :
137
157
138
158
- _docs.example.com/0.1/_
139
159
- _docs.example.com/0.2/_
0 commit comments