Hugo is a fast static site generator written in Go. Here are its key features:

  • โšก Ultra-fast build speed
  • ๐Ÿ“ฆ Simple installation and configuration
  • ๐ŸŽจ Rich themes and customization options
  • ๐Ÿ“ Content management with Markdown
  • ๐Ÿ”„ Hot reload for improved development efficiency
  • ๐ŸŒ Multi-language support
  • ๐Ÿ› ๏ธ Rich shortcodes and template functionality

Hugo can be used for various purposes such as blogs, portfolios, and documentation sites.

๐Ÿš€ Installing Hugo

While homebrew is the standard installation method, we’ll use the tar ball for better security considerations.

https://gohugo.io/getting-started/installing/

๐Ÿ“ฆ File Extraction

Create a bin directory under $HOME and place Hugo there.

make dir ~/bin
tar -xvzf ~/Downloads/hugo_X.Y_osx-64bit.tgz
./hugo version
mv hugo ~/bin

๐Ÿ”ง Path Configuration

export PATH="$HOME/bin:$PATH"

๐ŸŒ GitHub x Hugo

How to use Hugo with GitHub

๐Ÿ†• Creating a New Site

The following command creates a directory with your domain name.

hugo new site new-site.com

๐Ÿ”„ Git Initialization

git init
echo "# earth" >> README.md
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:account_name/git_rep.git

๐Ÿ“ For Sub-accounts

git remote set-url origin [email protected]:account_name/git_rep.git
git config remote.origin.url

โš™๏ธ Configuration File Setup

Add the following line to config.toml:

publishDir = "docs"

๐ŸŽจ Theme Installation

git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke

๐Ÿ–ฅ๏ธ Local Preview

hugo server

๐Ÿ“ Creating Content

hugo new posts/test.md

๐Ÿ“‹ Previewing Drafts

To preview content marked as draft: true locally:

hugo server --watch --buildDrafts

๐ŸŽจ Changing Themes

To change themes in config.toml, remove docs and rebuild the site. For custom domains, maintain CNAME when pushing to git.

  1. Change theme in config.toml
#theme = "ananke"
theme = "hugo-clarity"
  1. Remove docs and rebuild site
cp -p ./docs ./docs-old
hugo
cp -p ./docs-old/CNAME ./docs
  1. Push changes
git add .
git branch -m master main
git push origin main

๐Ÿ’ก Useful Tips

  • hugo server -D to preview including drafts
  • hugo new content/posts/post-name.md to create new content
  • hugo --minify to minify files during production build