ludenus
ludenus

Reputation: 1341

How to make hugo server use custom 404.html

doc page https://gohugo.io/templates/404/#automatic-loading says

hugo server will not automatically load your custom 404.html file, but you can test the appearance of your custom “not found” page by navigating your browser to /404.html.

QUESTION: is there a way to explicitly configure hugo server use custom 404 page?

Upvotes: 2

Views: 2874

Answers (1)

BugHunterUK
BugHunterUK

Reputation: 8968

This is not possible. Hugo will only produce a static website. You must use a web server in production NOT Hugo's development server.

Hugo should never implement an API of any kind. That's not what it was built for. I have used Hugo for a long time and have never needed such features from Hugo.

If you're able to run hugo serve on a server then you're likely also able to install packages. You should use nginx, or apache, or w/e you feel most comfortable with that's built for production.

Lots of tutorials online:

  1. https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04
  2. https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-to-use-custom-error-pages-on-ubuntu-14-04

It really isn't that difficult and it will save you many headaches in the long run. If you need something to quickly show your site to others (as this is often the case when wanting to use hugo's development server on a public facing machine) try https://ngrok.com/

Upvotes: 2

Related Questions