Real Hugo Quickstart Guide for the Novice
5/Nov 2017
When I started my road down Hugo, I was quite frustrated - the Hugo guides were difficult to follow and left out lots of details (basic facts, really) that a novice user would need to know. I mean, their Quickstart guide starts with macOS and the Install page is quite a mess. I’m not an expert on Hugo - rather this is me trying to document my findings and hopefully help someone out. So, here’s a real Hugo Quickstart Guide for the Novice.
My assumptions:
- You’re running Windows 10
- You have already acquired your own hosting (UW Students - it’s $2 / term at CS Club!)
- You have a nice text editor - eg. Notepad++.
What can Hugo (that executable residing on your computer) do?
- Generating a framework for you to fill for your static site
- Creating blank template posts that you can edit with your text editor
- Starting a ‘preview server’ of sorts, so you can build the current version before sending it live
- ‘Publishing’ your website - this creates a fully published version ready to upload
The other expecations you should have:
- Your posts will not be in a WYSIWYG (not Word), but will rather be written in a formatting language called Markdown. If you use Reddit you’ll already be halfway there! You will use your nice text editor to edit your posts and insert pictures.
- You will most likely use an FTP client such as WinSCP to upload your site afer it’s published through Hugo.
- You will also learn some very, very basic use of PowerShell to navigate directories.
Getting Hugo ready to go!
Set up the folder you want Hugo to be located. E.g. If you want it to reside in C:\Hugo, then also set up
C:\Hugo\bin
andC:\Hugo\Sites
. For the purposes of this guide, I will assume your directory isC:\Hugo
Download Hugo from here. At the bottom of the first post will be both the 32-bit and 64-bit Windows versions in a .zip file. If you’re not sure if you have 32 or 64-bit, consult this guide.
Extract the contents of the .zip you downloaded to the \bin folder (eg.
C:\Hugo\bin
) such that the contents of the\bin
folder arehugo.exe
,LICENSE.md
andREADME.md
.You can delete the original .zip file now.
Next, we set up Hugo so it can be accessed from Windows PowerShell - follow the instructions here. But these steps are a bit confusing even though I did it on two Windows 10 laptops at the same time so here’s some notes:
- You may not find ‘Advanced System Settings’ on the left as indicated, use the search bar instead.
- PATH is not in all caps, double left-click ‘Path’ anyway.
- On some versions of Windows 10, double left click on Path will show a box titled ‘Edit User Variable’ where all the fields already have a value. In the ‘Variable Value’ box, add your
\bin
folder to the end, separated by a semi-colon (e.g.%USERPROFILE%\AppData\Local\Microsoft\WindowsApps
was already in the box, the end result would be%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Hugo\bin;
). - In most other cases, everything will be displayed as a table, and you can click on the next blank row and type the directory (e.g.
C:\Hugo\bin
) directory you want to add.
Building a new Hugo Website
In Windows Explorer, navigate to
C:\Hugo\Sites
.SHIFT + right click
to open up a context menu, select ‘Open PowerShell window here’ or ‘Open command window here’ depending on which version of Windows you use.Type
Hugo new site test.com
and hit Enter.If it says ‘Congratulations! […]’ then you’ve done it right! In Windows Explorer, you will note that test.com has been added as a folder with the framework of a Hugo site built within.
Download a Theme. Beware that some themes are intended for blogs, and others for creating personal single page profiles. You can try the Red Lounge theme, which is the only one I got working easily out of the box. To download, go to the theme page, click Download, then on the GitHub page, hit
Clone or download
, thenDownload ZIP
Save the theme to
test.com\themes
and rename the folder to a simple name (e.g. Travelify). ensure that the next directory contains all the subfolders (i.e.test.com\themes\Travelify\archetypes
).Next, you should read the README.md that accompanies the theme you chose, so you can configure it correctly. The Red Lounge theme will ask you to add a number of fields to your config.toml saved directly in your
test.com
folder. Go ahead and add it to your config.toml, and also adding an image to\static\img
(you will have to create the\img
directory).[params] sidebartitle = "Test.com" sidebartagline = "Is super awesome" sidebarphoto = "/img/photo.png"
Navigate to
\test.com
by typingcd test.com
(There’s a quick primer on Command Line / Powershell a the bottom of this article!).Add a new post by typing
hugo new posts\my-first-post.md
. This creates a .md markdown file as so:C:\Hugo\Sites\posts\my-first-post.md
. Note thatmy-first-post.md
is organized within theposts
category.You can now edit the new .md file, by opening it up in your favourite text editor. The area within the
++++
contains information and attributes that Hugo uses when it builds your site. Feel free to edit the title line (keeping everything within"
double apostrophes). The content of your post goes underneath. For now, let’s use the following snippet of code below and paste it after the+++++
# This is my first post. Hello World! Click [here](https://github.com/adam-p/markdown-here) to see some tips on using Markdown to **format** *your* posts!
You’re ready to see your first site come to life (as a preview). Back in your Command line / PowerShell, navigate to
\test.com
and typeHugo server -D
, it will allow you to preview your website at http://localhost:1313 in your web browser.Open up the .md post in your favourite text editor again, and add the following to the bottom of your post, then save it.
I'm learning so ~~so~~ much! ![Example Image of Hummingbirds](http://www.gettyimages.ca/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg)
Return to http://localhost:1313 and you’ll see that the page has already been updated the moment you saved your newly updated .md file! Hugo builds as you
writesave!I almost ended the guide here, but it’s time to publish your filler site! Press CTRL+C while in the PowerShell / command line window to stop the preview server, and then type
hugo
. Hugo will generate your new site into\public
which you can then go and copy all the files into your live site, being sure to clear the target directory first!And now, you’re well on the way to building your own website. Go explore some more themes and go through the
README.md
of the theme you’re using. :)
Quick Primer on Navigation Through Command Line / PowerShell
dir
(e.g. directory) lists the contents of the current folder you’re in.cd
(e.g. change directory) allows you to change the directory you’re incd ..
allows you to go up one level (e.g. fromC:\Hugo\bin
toC:\Hugo
).- While typing the name of a target, you can hit
TAB
and it will autofill the rest of the name. (e.g. If you’re inC:\Hugo
and you typecd Si
then hitTAB
, it will now readcd Sites