Blogging with hugo – a static site generator

Hugo is a static file generator. It allows you to write your content in markdown then generates it into a blog or site.

# Installation

Since hugo is written in Golang, it compiles to a single binary that can be downloaded from its release page here.

  • Head over to hugo release page here
  • Click on the latest release and locate the tar file for your machine
  • Download the file. Use the following command if using the terminal
curl -LO
  • Extract the content locally
$ tar -xzvf hugo_0.123.6_Linux-64bit.tar.gz

x hugo
  • Move extracted content to the /usr/local/bin directory.
sudo mv hugo /usr/local/bin
  • Confirm that the command works as expected by checking the version
➜ hugo version

hugo v0.123.6-92684f9a26838a46d1a81e3c250fef5207bcb735+extended darwin/arm64 BuildDate=2024-02-28T18:29:40Z VendorInfo=brew

# Create new site citizix

To create a new site, run the following commands.

hugo new site citizix

Switch to the new site and initialize a git repository

cd citizix
git init

# Add a Theme

To add a theme, you need to identify your theme here I am using the theme noteworthy found in this git repo

Clone the site you like to the themes dir

git clone themes/noteworthy

To update to the new theme real quick, update the config.toml file, add the theme = "noteworthy" line.

Quick command

echo 'theme = "noteworthy"' >> config.toml

# Customize the Theme

Your new site already looks great, but you will want to tweak it a little before you release it to the public. As a quick start, you can copy the config.toml file in the exampleSite as a start and change the defaults.

# Create new blog post

To create a sample page for your blog, use the following command

hugo new posts/

# Start server

To run the server and view your site, do this:

hugo server -D

Navigate to your new site at http://localhost:1313/.

Feel free to edit or add new content and simply refresh in browser to see changes quickly (You might need to force refresh in webbrowser, something like Ctrl-R usually works).

# Build static pages

When you are done adding your content, you would want to build the static pages that will render your site.

Use this command

hugo -D

Output will be in ./public/ directory by default (-d/--destination flag to change it, or set publishdir in the config file).

Drafts do not get deployed; once you finish a post, update the header of the post to say draft: false

# Conclusion

In this guide we managed to install hugo and create a simple site with it.

Last updated on Mar 20, 2024 17:19 +0300
comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy