Custom 404 page for a Jekyll blog
When I moved my blog from wordpress to Jekyll hosted on GitHub Pages, I set the permalink format so that post links would not change. That works well for most posts, but some older posts have links created when my blog was hosted on SharePoint, and those were going to the default 404 page, which is not at all helpful.
The normal approach to changed link formats is to set up redirects in htaccess, but that isn’t an option with this sort of hosting.
Another option that would work is generating redirect pages - I’d probably go with that if I really cared about seo for the old posts, but it requires more work to identify the appropriate redirects and I don’t.
The first step was setting up a custom 404 page. Unfortunately you can’t use a jekyll generated page, but pasting all the html from a view source of the homepage into 404.html is easy enough. I probably could have generated something with jekyll locally and copied it out of _site before uploading, but the direct approach is good enough for now.
A similar script could be used for a redirect, but with a link it requires a particularly dense user to create an infinite loop.