Hugo Server for Production

In theory it’s completely possible to use Hugo as a production server, correct?

Is anyone doing this?

Certainly, such usage of Hugo takes it out of the “static site generator” category. And of course hosting needs would change. It would require listening on port 80, right? If this is the case, it’d be the only thing “servable” from the server it’s on, correct?

Certainly with cheap ssh hosting (such as Digital Ocean, Linode, or another) this could be a really sweet (and powerful) setup. Combined with a client-side front-end admin app (talking to the Hugo server) the potential seems incredible.

Anyone else thinking along these same lines?

  1. It would still be a static generator. The server is a “separate product”
  2. Server at port 80 or any other port then put a reverse proxy in front of it (nginx, apache)

A lot of people are using hugo as a production server. Performance is about the same as Apache.

Good to know… hadn’t realized this. What’s the benefit here? Perhaps they’re extending Hugo with other features (even connecting it to a database or something)?

Also, @spf13 and others:

Are there any reasons not to run Hugo in watch mode as a production server?

  • CPU/energy usage would be one vote against it

Indeed. So what would be some ways to trigger a rebuild on certain actions? I believe this is where the idea of “hooks” come in handy, right?

cron is simple … building every 10 minutes should be plenty.

1 Like

If you’re looking for nearly instant builds on change, then Github webhooks is a good way. I use Jenkins to respnd with the commands so I don’t have to wait for cron runs. But, it’s probably safe to run cron every 60 seconds and call it done.

I serve the files from Nginx because Nginx is a much faster static file server than our old friend Apache.

@isaac It depends on the OS you are running this on, but in general the feature isn’t really designed for this. It opens a lot of files and you will run into OS limits relatively quickly.

I don’t think it would burn resources too heavily, certainly less than something like wordpress, but it does beg the question of why not do this on a cron or with triggers/hooks.

I’ve pinged the guys who wrote the watching library Hugo uses to see if they have any feedback here as well.

In terms of updates/hooks/cron - a simple post-commit hook at the git-level is another alternative. I use something like this: http://imperialwicket.com/automatically-deploy-hugo-to-s3-and-cloudfront/

1 Like