@@ -55,6 +55,20 @@ Check out the versioning example to see it in action –
5555 [version example] : https://squidfunk.github.io/mkdocs-material-example-versioning/
5656 [Why use mike?] : https://github.com/jimporter/mike#why-use-mike
5757
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+
5872# ## Version warning
5973
6074<!-- md:version 8.0.0 -->
@@ -133,7 +147,13 @@ mike deploy --push --update-aliases 0.1 latest
133147` ` `
134148
135149Note 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 :
137157
138158- _docs.example.com/0.1/_
139159- _docs.example.com/0.2/_
0 commit comments