How do you go about migrating your existing blog entries from one URL scheme/pattern to another without breaking existing links scattered outside of your blog?

When I first setup this blog I didnā€™t pay too much attention to SEO or how the automatically generated URLs were turning out. Hindsight is 20/20, and that was a big mistake. As it turns out, the way I had been organizing my posts as /<category>/YYYY-MM-DD-SLUG.md would mean they would get generated as /:category/YYYY/MM/DD/SLUG. Which wouldnā€™t have been so bad if my slugs handā€™t always been an entry count for that date, meaning that they would always be YYYY-MM-DD-01.md šŸ™ƒ

I know, I know, the hubris of thinking Iā€™d be writing more than one post per day, when I havenā€™t even manage one per year is enormous.

Anyway, I wanted to change this, and thankfully thereā€™s a pretty nifty jekyll-redirect-from plugin to help you create the redirect pages in order to preserve an existing URL, but having it now point at something else (or vice-versa).

So now, if I did everything right, older URLs for this blog will now redirect to the updated slug-based variants. E.g. /swift/2021/07/23/01 will redirect you to /detecting-memory-leaks-via-tests-part-2.




# Sources