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
| |
- Extract the content locally
| |
- Move extracted content to the
/usr/local/bindirectory.
| |
- Confirm that the command works as expected by checking the version
| |
Create new site citizix
To create a new site, run the following commands.
| |
Switch to the new site and initialize a git repository
| |
Add a Theme
To add a theme, you need to identify your theme here https://themes.gohugo.io/. I am using the theme noteworthy found in this git repo https://github.com/kimcc/hugo-theme-noteworthy.
Clone the site you like to the themes dir
| |
To update to the new theme real quick, update the config.toml file, add the theme = "noteworthy" line.
Quick command
| |
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
| |
Start server
To run the server and view your site, do this:
| |
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
| |
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.