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.
- Change theme in config.toml
#theme = "ananke"
theme = "hugo-clarity"
- Remove docs and rebuild site
cp -p ./docs ./docs-old
hugo
cp -p ./docs-old/CNAME ./docs
- Push changes
git add .
git branch -m master main
git push origin main
๐ก Useful Tips
hugo server -Dto preview including draftshugo new content/posts/post-name.mdto create new contenthugo --minifyto minify files during production build