+++ date = ‘2025-01-06T17:34:21Z’ draft = true title = ‘Hugo: A Static Site Generator’ +++
In this post I give an introduction to what I think is the best static site generator: Hugo.
Hugo is an open-source static site generator written in Go. It takes structured content, often written in Markdown, and compiles it into static HTML, CSS, and JavaScript files.
Follow these steps to set up your first Hugo site
First, ensure you have Hugo installed. Use your package manager of choice:
# Windows
winget install Hugo.Hugo.Extended
Initialize a new Hugo site:
hugo new site my-new-site
This command scaffolds a directory structure optimized for modular development.
Browse Hugo Themes or create a custom theme to match your project’s needs. For example:
# change directory to your newly created site
cd my-new-site
# this will insert a template used to display your site
git submodule add https://github.com/vimux/mainroad.git themes/mainroad
That is the theme this site uses. The cool thing about themes is you can quickly change how your site looks.
Set the theme in config.toml
:
theme = "mainroad"
Hugo’s Markdown support simplifies content creation. Create a new post:
hugo new post/first-post.md
This will generate a page first-post.md in the post folder with the following contents
+++
date = '2025-01-06T17:26:44Z'
draft = true
title = 'First Post'
+++
You can edit the generated file in content/posts
.
Hugo’s built-in server lets you preview your site with hot reloading:
hugo server -D
Access your site at http://localhost:1313
.
This means you can view your change live it can help you write content quickly
When your site is ready for deployment, run:
hugo
Static files will be placed in the public
directory, ready for deployment.
Static sites are highly portable and can be deployed across various platforms. Here are some examples:
Hugo Modules: Enable component-based development by reusing content and templates across projects.
hugo --templateMetrics
to optimize template rendering.In the hugo.toml file we put configuration options for the generate site for example
googleAnalytics: if you have set uip a google analytics account add this property and it will generate the correct addition to your site.
Quick Start Guide
How to host on github pages
Hugo Discord
Hugo Tips
Markdown Tutorial