Creating a 404 error page in Metalsmith

Just a quick post for those that are looking on how to create a 404 error page using Metalsmith. Simply generate a 04.html page in the root of the website. This would mean creating a page in /src/, maing sure to add the front matter definition of permalinks: false eg:

title: 404 not found page
layout: post.hbs
permalinks: false

This is so that /404.html is created rather than 404/index.html, as is the default.

Also, you may need to configure your webserver so that the 404.html is picked up when a page isn’t found. FWIW, Netlify will pick up a 404.html page automatically.