Why Hugo
In the previous post on Hugo I described why I ended up with a Static Site Generator, in this on I will describe my reasons for choosing Hugo.
Easy to get started
Hugo is written in Go and is compiled for all major (and some not so major) operation system. And it’s compiled to ONE single file and that is all you need. No need for downloading a runtime, installing a million packages and having updates breaking corners of the site - I’m look at you, NodeJS!
To create a site, just download a single binary, put it in your path and then run the command:
hugo new site mysite
Then Hugo creates a full site structure and you have a skeleton for a site.
Even better is the experience when you want to see your site. You could just write Hugo
in a command prompt and it will compile the site to a folder called /public
and then open that folder in a browser. But a much better way is just to run the command
hugo server -D
This start a webserver that watches the folders and live reloads every time you save a file.
This is brilliant when you are changing templates or tweaking CSS - or just want to see how a post looks.
Templates
When you want a site that look a little better than something your 5 year old nephew (or your equally hypothetical developer in his late thirties) could have designed there is a lot of themes to chose from. Templates is just a collection of HTML files for header, footer, lists and so on - typically it’s just a Git repository you clone.
A theme is also a great way to dig a bit deeper into Hugo and how to customize templates to your own liking. Hugo makes use of Go templating and this gives a lot of possibilities regarding list of post etc…
Folder structure
Another very neat thing is the structure of a project. Basically you have 5 folder (and maybe a couple more):
Themes is the files a friendly guy from the Internet made to make your site look nice.
Layout is where you alter the theme by adding you own customizations to the themes template or add new templates.
Static holds all your static content (surprise!) as images, CSS, and so on.
Content (yet another surprising name) holds your pages content. This just a bunch of markdown files in roughly the same structure as you want them to appear at your site.
This structure makes a ton of sense as it’s separates content and layout very neatly, and it’s very easy to add thing to the proper folders.
Conclusion
Al in all Hugo have been a breeze to get into, and every time I think I hit a wall there is a lot of help to get in the Hugo Forums, and so far I have found answers to all my (Hugo related) answers!