Dynamic(*) 404 pages for static blogs
Static blog hosting is great, I’m a big fan, I even wrote my own static blog generator. However, sooner or later, you will have to solve problems that used to be trivial when you had your blog on your own web server, and had scripting capabilities to deal with them, but now they seem a bit harder.
One of them is how you deal with pages that have been moved. For example, I used to host this blog on tumblr. Post URLs looked like blog.vrypan.net/posts/post_id. When I moved to bucket3, I decided to move to a new URL scheme and now the same post is found at blog.vrypan.net/YYYY/MM/DD/post_id (the old post_id).
I host my blog on amazon s3. Until later, S3 allowed you to define a 404 page, but had no way to do redirects (they recently added 301 redirects). But you may have decided to host your site to github, or some other provider os “simple-static-html-hosting”, that doesn;t offer redirects as an option.
How you create the JSON data file depends on your setup and your needs. I wrote a python script that went through my posts, and used the id and the post date to determine the old and new URL. Your case may be different, for example you may have just a handful of URLs that have moved and you can hardcode them by hand, or you may have changed the base directory of your blog (ex, from /blog/ to /weblog/ or something).
Example: If you go to an old URL, say http://blog.vrypan.net/post/16306741725/ you will see that you get a link to the new one.
-- (*) not really dynamic, but...