How to Set Up a Custom 404 Page With Hugo

Published: 2024-04-28 | Updated: 2024-05-16

The problem

When I built this site using Hugo I didn’t give much thought to putting up a custom 404/Not Found error page. But after all the excitement of launching a new thing died down I discovered my site was snowing very ugly Apache error page when a 404/Not Found error occurred.

Here’s how I set up a custom 404/NotFound page for this site.

The Solution

First, create a 404.html page in your layouts folder. I simply copied my home.html - an easy choice because most, if not all 404 pages I’ve run accross link back to Home anyway. So why not?

Second and last, I needed to reconfigure and reload Apache.

Done. Navigate to some non-existent URI on your site and behold the glory of your custom 404.html