gohugo in production


Running gohugo in production can be a little confusing. Not because the documentation is bad, because it really is good for an open source project. However, there are some things you should do, before running your site on a public facing platform.

Pre req’s:-

  • Ubuntu 16.04+
  • shell access to your node
  • ssl cert (you don’t have to, but you know you should)
  • hugo is installed and you have created a hugo user in your distro of choice.

The bash start script

I put this in /opt/scripts/start.sh in this example:-



$HUGO_BINARY server -p $HUGO_PORT --disableLiveReload --bind --logFile $HUGO_LOG --appendPort=false --baseUrl=$HUGO_BASEURL --source=$HUGO_HOME

Make sure the script is executable with chmod u+x start.sh. Important points regarding the command line args used in this example:-

  • --disableLiveReload is massively important if you run ssl on your site. Without disabling live reload you will see nasty unsafe invocation errors in your browser because livereload uses ws:// which is not secure. The downside of this is - if you update your content you will have to restart your hugo service. A small price to pay to have a secure and trusted website.
  • --bind allows all interfaces on your server to listen for incoming web requests.
  • --baseUrl= hugo is a young project and there are some bugs. This is one of them. The baseUrl is a config directive but is also needed in the command line arguments to allow the loading of static resources relative to your current path.

The systemd service script

This following script should sit in your /etc/systemd/system/ dir:-

Description=Hugo Blogs


You can of course edit the script to suit your description and project structure. You then need to run the following commands:-

systemctl daemon-reload
systemctl enable my_systemd_script.service
systemctl start my_systemd_script.service


You now have a running blog in production. Congratulations!

Coming soon:-

  • Running gohugo in docker.
  • Setting gohugo up in aws with an ELB.
  • Mangaging pre production/production config properties.
  • Making build jobs for your project using Jenkins.
Tags// , , ,
More Reading
Older// welcome