New Blog Site
So I’ve just created my first blog site! (HooRah) It uses Hugo, let me show you how I set mine up.
What is Hugo
If you haven’t come across it before, Hugo is a static site generator. It’s actually very powerful, with more features than I will probably use. It should do what I want without too much difficulty.
Installing Hugo
Following the Quick start guide to install hugo was very easy, although I would recommend installing the latest release rather than from repository (using apt or yum). Installing from apt seemed to work fine at first, but I found it to be quite an outdated version and had compatibility issues. Installing the .deb using dpkg solved this easily.
- Download the latest release for you architecture and OS (in my case linux/amd64 .deb)
- Install the package
- for debian-like distros
sudo dpkg -i <downloaded_file>
- for debian-like distros
- Run
hugo versionto check that the installed version is what you expect.
Setting up a new site
Hugo makes it very simple to create a new site.
- Run
hugo new site <site-name> - Enter the newly created directory
cd <site-name> - (Optional) Initialise the new site as a git repository
git init - Add a theme
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/anankeecho "theme = 'ananke'" >> hugo.toml
- Start the server
hugo server
Adding new content
Now that we’ve created our initial server, we can add some content. Again, hugo makes this very easy.
hugo new content content/blog/new_blog.md
Hugo automatically detects the file ending and creates a new content file from a set of templates.
Publishing
With Hugo, publishing is the act of generating all of the static files needed for your website. Publishing is as simple as:
hugoORhugo --minify
There are other options too, but i’ll leave those for you to take a look at!
Deploy
Hugo has several methods of deployment, including cloud hosted options. We’re going to be using the basic rsync method as I will be hosting this statically with nginx on my own server.
rsync -avz --delete public/ USER@HOST:/path/to/webserver/
It’s really that simple. Setting up Nginx and certbot to host these is a separate matter which I’ll cover in a future blog post.
Edit away
You’ve now created your site! Now you can add more content pages, deploy, and show off to the world.
There’s loads more that Hugo can do, but for now that’s as much as I’ve worked out.