Change URLs without breaking old links in Jekyll
Using Jekyll and static site generators comes with its own set of problems, one of them is changing URL formats without breaking the previously used links. Thankfully, the solution is fairly simple.
When I started this blog using Jekyll I was amazed at the power it had, using simple plain markdown files and some yaml metadata. One of my favorite features is adding a custom permalink for each blog, which lets me change it from the default, for example, this post would normally have the following URL:
https://joelchrono12.xyz/2022/06/23/change-urls-without-breaking-old-links-in-jekyll.html
However, by setting a permalink
in the yaml metadata, I can simply have something like:
https://joelchrono12.xyz/blog/change-urls-without-breaking-old-links/
Which is shorter and easier to type.
However, before doing my rofi script for automatic post creation I initially created my markdown files by hand, and I didnβt really had a format to follow, some of my posts had /blog/post.title
, others had no permalink set at all, and others just had /post.title
.
This means that the generated static files are all over the place, and I kinda wanted to clean that up.
The solution is really simple. I just installed the jekyll-redirect-from plugin. After reading the README in their repo, I realized this was exactly what I needed. I wonβt really explain it here since its fairly easy to do, but feel free to ask me if you feel like it.
You can test out how the plugin works on my website, here are some of the old URLs that should now redirect you to the new one. You may also find some of those old posts of mine kinda interesting too!
- A comparison on Newpipe and Youtube Vanced
- Privacy focused browsers for Android
- Asking for forgiveness for small things
- Changing my Android custom rom
Even in those old articles I link to some more posts that are still using a different format, which will be redirected too. If you found this useful please let me know!
Comments
If you have something to say, leave a comment, or contact me βοΈ instead
Reply via Fediverse
You can reply on any Fediverse (Mastodon, Pleroma, etc.) client by pasting this URL into the search field of your client:
https://benign.town/@joel/108528967322278227