Quick Start doesn't work on Ubuntu

Brand new hugo user here.

I am running Ubuntu 16.04 and have installed go and hugo using apt-get.

When following the Quick Start guide I run into issues.

Step 1: Install Hugo
brew install hugo
This step works. The reported version of hugo is “Hugo Static Site Generator v0.16-DEV BuildDate: 2016-02-06T12:14:17-05:00” which in typical Ubuntu fashion is quite out of date.

Step 2: Create a New Site
hugo new site quickstart
This step also seems to work.

Step 3: Add a theme
The anake theme seems to be installed correctly.

Step 4: Add Some Content
hugo new posts/my-first-post.md
This is where my problems begin. The above command gives a single line error message: “Error: Near line 2 (last key parsed ‘’): Expected a top-level item to end with a new line, comment or EOF, but got ‘-’ instead.”

I searched online and found that the issue could be caused by the lack of an archetypes/default.md file. (At this point in time I have an archetypes/ folder but it is empty.) I created this file with the following suggested content:

+++
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = {{ .Date }}
draft = true
+++

Then I tried following Step 4 again, but I get the same error.

Running hugo check gives the following errors.

ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/_default/baseof.html:2: function "default" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/_default/terms.html:12: function "relLangURL" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/index.html:6: function "default" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/page/single.html:7: function "humanize" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/partials/menu-contextual.html:8: function "humanize" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/partials/page-header.html:9: function "default" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/partials/site-footer.html:4: function "now" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/partials/site-header.html:1: function "default" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/partials/summary-with-image.html:23: function "default" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/partials/summary.html:3: function "humanize" not defined
ERROR: 2018/10/13 13:30:54 template.go:350: template: theme/partials/tags.html:4: function "relLangURL" not defined
No source files provided.

I searched online with these errors and it was suggested to upgrade to V0.16-DEV, but that is the version that I am running … unless there are multiple different versions of V0.16-DEV?

Any help would be appreciated.

tldr Step 4 of the Quick Start doesn’t work on Ubuntu 16.04 even when following the most common suggested fixes online more than once.

And that is why you experience the problems you mentioned.

First of all you only need to install Go if you plan to compile Hugo from source.

Since you are talking about installing Hugo from a binary you do not need Go.

Now completely remove Hugo 0.16 and Go (whatever version it is in apt) through Synaptic.

Then either install the latest Hugo binary following the Instructions over here

OR install the Hugo snap. Instructions here

The snap package is automatically updated whenever there is a new release so choose this option if you want to have Hugo always up to date without having to do manual updates.

After doing the above then go through the Quick Start Guide and if you encounter problems ask us here.

Thank you for the quick reply.

I removed Hugo and Go, and started following your second suggestion (ie snap install).

Running snap did not initially work on my system, even though it is supposed to be included in Ubuntu 16.04. After searching online I found that installing snapd using apt-get would fix this issue, and it seemed to do the trick. However, I have never used snap before, so I am not completely sure that it installed correctly.

Next, I followed the Install Hugo guide and ran snap install hugo --channel=extended. This seemed to work as there were no errors generated.

Unfortunately, I can’t seem to run hugo. More specifically, running hugo results in “command not found”. I tried opening a new terminal window, but that didn’t help.

Any suggestions? Or should I move on to the tarball?

I actually installed hugo on ubuntu last night. If it helps, here’s what I did:

  1. Download zip of hugo binary from hugo releases (I grabbed hugo_0.49.2_Linux-64bit.tar.gz)
  2. Unzip it
  3. Run below to copy it to /usr/local/bin/ since this is already on your PATH
sudo cp path/to/unzipped/hugo /usr/local/bin/
  1. Confirm installation with hugo version
2 Likes

If memory serves me right you need to install the Hugo snap with sudo.
i.e. sudo snap install hugo --channel=extended

EDIT
Also you can verify your snap installation with snap version

Snap seems to be installed properly, and hugo also seems to be installed. However, I can’t run hugo.

awilliams@xxx:~$ snap version
snap       2.35.2
snapd      2.35.2
series     16
galliumos  2.1
kernel     4.8.17-galliumos

awilliams@xxx:~$ snap install hugo --channel=extended
snap "hugo" is already installed, see 'snap help refresh'

awilliams@xxx:~$ hugo
bash: hugo: command not found

awilliams@xxx:~$ sudo snap install hugo --channel=extended
[sudo] password for awilliams: 
snap "hugo" is already installed, see 'snap help refresh'

awilliams@xxx:~$ hugo
bash: hugo: command not found

I haven’t used snaps before, so I’m not sure how to proceed without a big diversion. So I’ll try the third option as suggested by @zwbetz and will report back. Thank you both for your help thus far.

I should have also mentioned that I tried removing hugo via snap, and reinstalling it using sudo. I also tried to do sudo and non-sudo installs of hugo without channel extended. In each case hugo seems to be installed according to snap, but I issuing the hugo command does nothing.

awilliams@xxx:~$ snap remove hugo
hugo removed

awilliams@xxx:~$ sudo snap install hugo --channel=extended
hugo (extended/stable) 0.49.2 from Hugo Authors installed

awilliams@xxx:~$ hugo
bash: hugo: command not found

awilliams@xxx:~$ snap remove hugo
hugo removed

awilliams@xxx:~$ snap install hugo 
hugo 0.49.2 from Hugo Authors installed

awilliams@xxx:~$ hugo
bash: hugo: command not found

awilliams@xxx:~$ snap remove hugo
hugo removed

awilliams@xxx:~$ sudo snap install hugo
hugo 0.49.2 from Hugo Authors installed

awilliams@xxx:~$ hugo
bash: hugo: command not found

awilliams@xxx:~$ snap list
Name  Version    Rev   Tracking  Publisher     Notes
core  16-2.35.2  5548  stable    canonical✓    core
hugo  0.49.2     2759  stable    hugo-authors  -

For good measure, I also tried opening new terminals and rebooting, but nothing changed. On to the tarball!

I followed @zwbetz’s steps and had Hugo properly installed and running in a matter of minutes. Yay!

The Linux section of the Install Hugo page was my biggest enemy in this process.

  • The first suggestion is to use snap, which didn’t seem to work for me.
  • The second suggestion is to use apt-get and that didn’t work for me either (and it seems that it is a known issue).
  • The approach that worked for me is actually listed under the macOS section of the page.

In other words, to install on Hugo on Ubuntu, you should ignore all of the suggestions for Linux and instead follow the advice for macOS. That’s really bad.

Thank you again for the help – otherwise, I would have given up!

Please considering paying it forward by updating Sign in to GitHub · GitHub with better instructions, while you still have them fresh in mind! :slight_smile:

1 Like

Unfortunately, many new users may feel hesitant to update instructions even though they may be well qualified for their particular environment i.e. Linux.

I believe it really should be mostly the Hugo experts who evaluate the posts and add the relevant documentation in a way which would help those less experienced, given current and similar issues addressed in posts. Over time this should reduce the FAQs.

I personally find the “list of steps” approach to documentation best in most cases since it is easily reproducible for both the person following the steps as well as the person troubleshooting. I am glad it worked in this case!

Hi @awilliams,

Sorry, you were unlucky, but thank you for reporting this back to us.

Believe it or not, the instructions for Linux do work for many people, including Ubuntu users, though the instruction is indeed catered towards newer versions. For example, the new Ubuntu 18.04 LTS was released with Hugo v0.40.1 which you could install with apt-get install hugo.

As for snap not working on your Ubuntu 16.04 LTS, that is a bit strange indeed especially since Ubuntu 16.04 LTS comes with snap support by default. Could you please check and make sure /snap/bin is in your PATH, and that /snap/bin/hugo exists?

That said, I do agree with you that the Install Hugo page does need a reorganization. It has been worked on by many different people over time, and it has become somewhat inconsistent, with generic instruction (e.g. compiling from source) misplaced under the macOS-specific instruction, and with various “caveats” removed for the sake of simplicity, but at the cost of sacrificing ease troubleshooting.

Wrote a small post on using Snap to install Hugo on Fedora and Ubuntu. In this case, I used the edge channel, but steps are given to install from other channels. Hope this helps.

https://zwbetz.com/use-snap-to-install-the-hugo-edge-version-on-fedora-and-ubuntu/

Thank you to @anthonyfok and @FelicianoTech for their Snap-related contributions.

1 Like

Firstly, thanks for a great program!! I have been using it on Windows 7 for ‘hobby/personal blog’ websites.

Just transferring my OS over to Ubuntu 18.04 LTS (dabbled for a while but basically a newb!) and came across the same problem.

Tried to install through Snap and apt, but when starting the program, a window appears (possibly the terminal window) and then promptly disappears again. Hugo does not show up in Applications using either method. Also tried the extended/edge channel for Snap.

Hugo is a single binary, so it will not show up in the usual list of GUI apps. If you open a terminal window and run hugo version what output do you get?

Ah, OK - needs to run the same as in Windows (me feeling fool now!).

hugo version = Hugo Static Site Generator v0.40.1 linux/amd64 BuildDate: 2018-04-25T17:16:11

Running Hugo from Terminal brings up the ‘Unable to locate Config file…’ message, as per windows on first run.

I did have Version 0.5 installed, but would appear to have regressed from that in my trying to understand what was going on.

Thank you for your help!

Yep, so you have it installed. That’s an older version by the way, the lastest stable release is 0.50. I’d take a look at the Quick Start next.

Understand I should have 0.50, and will update soonest. Thank for the link.

As I mentioned, have used it on Windows, it is just this steep learning curve with Ubuntu I have to get through.

Your help is much appreciated!

1 Like