Hugo
Hugo: a fast, simple static site generator
Why Hugo is worth using
Hugo is a static site generator written in Go. You write your content in Markdown, Hugo combines it with your templates, and out comes a folder of plain HTML, CSS, and JavaScript you can host almost anywhere.
- It’s fast. Hugo builds thousands of pages in seconds, and the dev server live-reloads your browser the moment you save a file.
- It’s a single binary. No
node_modules, no Ruby gems, no runtime to keep updated. Install one program and you’re done. - Content is just Markdown. Your posts are plain text files you can keep in git, edit in any editor, and move to another tool later if you want.
- Static output is cheap and secure. No database or server-side code means there’s very little to attack and hosting is often free (GitHub Pages, Netlify, Cloudflare Pages, etc.).
- Batteries included. Taxonomies (tags/categories), RSS, sitemaps, image processing, and Sass/JS bundling all come built in.
Installing Hugo
Install the extended edition. Many themes need it for Sass/SCSS support.
- macOS:
brew install hugo - Windows:
winget install Hugo.Hugo.Extended - Linux (Debian/Ubuntu):
sudo snap install hugo. Theaptpackage is often out of date, so for the newest version grab a.debfrom the Hugo releases page. - Arch:
sudo pacman -S hugo
Check that it worked:
hugo version
The output should include +extended.
Setting up a new site
hugo new site my-site– create the project foldercd my-sitegit init– start a repo (themes are usually added as git submodules)- Add a theme, for example:
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke echo "theme = 'ananke'" >> hugo.toml– tell Hugo to use ithugo new content posts/my-first-post.md– create your first posthugo server -D– start the dev server, including drafts
Open http://localhost:1313 and you should see your site. New posts start with draft = true in their front matter. Change it to false, or remove the line, when the post is ready to publish.
Project layout at a glance
hugo.toml– site config (base URL, title, theme, menus)content/– your Markdown pages and postslayouts/– your own templates, which override the theme’sstatic/– files copied as-is (images, favicons, etc.)assets/– files Hugo processes (Sass, JS, images)themes/– installed themespublic/– the generated site (created when you runhugo)
Run hugo server for dev
hugo server
Useful flags:
hugo server -D– include draft contenthugo server --disableFastRender– do a full rebuild on every change (helps when the page looks stale)hugo server --bind 0.0.0.0– make the server reachable from other devices on your network
Build for deployment
hugo– base production buildhugo --gc --minify– minified production build that also cleans up unused cache fileshugo --gc --minify -b https://your-production-domain.com/– set the production URL if needed
The finished site is written to the public/ folder. Upload that folder to any static host.
note
- The correct
baseURLshould be set in yourhugo.toml(older sites useconfig.toml) - Add
public/andresources/_gen/to.gitignoreif your host builds the site for you