I'm reorganizing a collection of documentation that is hosted as a github repository. Is there any way to create redirects in the repository so that anyone who has bookmarked a file that has moved is redirected to the new location?
I am not aware of any way to set up redirects for moved files. The next best thing to do depends on what you need?
Do you just want to avoid broken URLs? Then distribute URLs that are more permanent. One way of doing that is locating the file you want to link to on GitHub, then pressing y which will replace the branch name with a commit SHA. For example, if you're at https://github.com/fred/frobbler/blob/master/LICENSE.md
and then press y, you're browser will reload https://github.com/fred/frobbler/blob/{commit-sha}/LICENSE.md
. Even if LICENSE.md
were removed or renamed in later commits, that URL will stay valid. Of course, people will now be linked to a particular (historic) snapshot of that file.
Do you want to forward people to the latest version of the previous content? In that case, you'll likely need to keep the old document around and put a notice in it where the new document can be found. Or, you use one of those URL abbreviation services to generate a public URL, which allows you to edit the actual URL later on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With