Sure, I’m playing around to build a small RESTful get API with Hugo. Had fun so far, just want a proper json response along with error code to return when no content is found.
You can just make whatever you want as 404.json and then set that as the thing your API errors to. I mean, that is how it works in HTML, we tell the server to serve the 404.html we generated.
Addendum: if for some reason you are including additional info in your 404.json (such as build time or something), you can add it to the home page as a custom output format.
Doesn’t seem to work, that may be because my homepage already is set for that index.json
Or I’ll just drop it in static/ but I was hoping for something more sophisticated than that in case I need different error code by sections or something.