Continuing our series on the Internet Archive, you may recall the last part on the Wayback Machine. Well, today we’re going to go over one more extension of its power that was big enough to get its own part, the smart 404 handler!
If you have your own site, you have probably deleted a page or post by now. Whether on purpose or by accident, you can control what’s on your site, but you can’t control the links to it that already exist elsewhere. When those links direct to your deleted content, the visitor sees a boring 404 Not Found error. But, what if I told you that you could use the Wayback Machine to offer those disappointed visitors a glimpse of the content they missed?
A few years back, the folks behind the Internet Archive debuted their smart 404 handler for free use, and it still works great! Simply add the code from the earlier link to your custom 404 page, and it will work like magic. If you have a WordPress site, your theme more than likely has a 404.php file. If you have not already, now is a great time to start a child theme, so your changes aren’t lost if the theme is updated. Now, simply find where the content of your 404 page ends in the 404.php file (the content you visibly see on the page, not the entirety of the code), and add the code right below it. Here’s how the relevant section looks in the Sorbet theme’s 404.php file:
You won’t see anything if the former page or post wasn’t archived by the Wayback Machine. If you did it right though, and you land on one that has been archived, you’ll find a welcoming message with a link to the most recently archived version. It will look something like this:
Thanks to the smart 404 handler and the Wayback Machine’s over 462 billion archived pages, the experience of missing out on lost content could be a thing of the past.
This bring us to the end of our series on the Internet Archive, for now. If you enjoyed your brief tour, don’t forget that they need donations to be able to provide all this for free. Until next time, enjoy everything the Internet Archive has to offer!