Installing Hugo on Ubuntu

Is there a straight forward way of installing and running Hugo on my Ubuntu server? I would love to give Hugo a shot but I can’t seem to get it up and running despite following this tutorial step-by-step: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-hugo-a-static-site-generator-on-ubuntu-14-04

Any help would be greatly appreciated!

Isn’t Hugo available in the Universe Repository? https://packages.ubuntu.com/search?keywords=hugo

If you’ve got Universe enabled, it should be as simple as sudo apt-get install hugo.

1 Like

Setting it up and testing it on http://domain.com:1313 seems to work but how do I get it to work on http://domain.com?

I can’t for the life figure that one out and it’s killing me.

you might need to add a \ to your baseURL in your config.toml. Should have a trailing \ there, whether you have the domain in it or not.

Are you wanting to serve your site from this Ubuntu server?

I think you’ve got two options:

  1. Use a webserver to serve out the pages (e.g. Apache or NGINX). To do this, you need to get Hugo to build the static site hugo --publishDir /path/to/wwww/server/directory. Or
  2. Use Hugo as your webserver. To do this run hugo server --port 80 - so it will be serving pages to http://domain.com.

I’d be going for option 1.

The hugo server webserver is not meant for production. Either host your site on your ubuntu server using a webserver meant for production (like apache, nginx, or even caddy) or host on a webserver at a hosting or vps service. I use webfaction and amazon S3 but, you could use a digitalocean droplet or a linode etc.

Use hugo server and switches to host locally to http://localhost:1313 or whatever port. I use this:

hugo server --navigateToChanged --buildDrafts --watch --verbose --source="/path/to/myproj" --config="/path/to/myproj/config.toml" --port=1234

Note that that does not keep a copy of the built files on your disk. There is a switch for it though. Look in hugo server --help

When you’re ready to publish do hugo with switches to put it in a local folder, then use any of a number of methods to put the folder up on the host where you can serve it. For example, sftp or rsync. Like:

hugo --config="/path/to/myproj/config.toml" --baseURL="https://mydomain.com" -s /path/to/myproj/ -d /tmp/mydomain.com

Then you have a folder in /tmp you can transfer where you need it.

EDIT: took a look at that tutorial. It assumes everything’s happening on a DO droplet you’ve provisioned. It’s a couple years old so maybe the versions are newer etc. Personally, if you’re editing in nano like it has in the tutorial, that’s going to get painful quickly. It’s more comfortable, to me, to edit everything locally using a nice editor, then use hugo server to view progress. Then do a hugo to build the files and push them up via, for example, rsync.

1 Like

I’m sorry that I’m terrible at communicating what I’m doing. Yes, I’m using a Ubuntu VPS and am looking at hosting the site on that Ubuntu server.

Use Ubuntu and a web server (Apache works), and copy your public directory created by Hugo and upload it to where your web server is configured to serve files.

If you need help configuring a web server for Ubuntu, please keep searching, there is plenty of info out there on the web. Keep support threads here about Hugo-specific subjects, please.