jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
551 stars 47 forks source link

Redirecting from non-version URL to latest URL #223

Closed EnriqueL8 closed 3 months ago

EnriqueL8 commented 3 months ago

Hi all!

Thanks for building a great tool 😃

We have recently moved our project Hyperledger FireFly to mkdocs and use mike to manage versions, you can see the docs here https://hyperledger.github.io/firefly/latest/.

We are using all the mike deploy command to handle versions and it all works well but unfortunately there is a lot of content online that references our old URLs for example https://hyperledger.github.io/firefly/reference/namespaces/ which does not contain the latest path parameter. For this URL, a 404 page is rendered so I would like to be able to redirect to https://hyperledger.github.io/firefly/latest/reference/namespaces/.

A few things I've looked at:

Thanks in advance @jimporter !

jimporter commented 3 months ago

Sorry, but that's not supported. While it's theoretically possible to determine the correct place to redirect, the static nature of the pages makes it painful to actually implement, at least in a way where I could feel confident it wouldn't increase the support burden of this project. Here are the ways I can think of to solve this:

  1. (The best way, in my opinion) Upgrade to a proper web server where you can set up more complex redirect rules. That would solve this neatly, as well as eliminating the need for redirects elsewhere in mike (index.html and the version aliases). Then you could deploy the contents of the gh-pages branch to that server and it should all just work.
  2. Manually set up redirects from the old pages to the new ones. Since this is a one-time operation, it should be pretty simple. You could just use the redirect template from mike and make copies in all the old locations. Mike shouldn't clobber those, since it's built to only update the versioned pages (and versions.json). Maybe you could use mkocs-redirects for this, though I'm not sure there's much point; it's not like you'll have to change the redirects after you've set them up (except maybe to delete them a few years down the line).
  3. Make your own 404 page that does redirection. This is likely to be annoying to do, as you'll need to be careful about redirect loops.
  4. Switch to something like ReadTheDocs and just redirect the old site wholesale to that. This lets you get all the fancy features from RTD too.
jimporter commented 3 months ago

Closing. If this becomes supported in mike at some point, it would be via #72.