Skip to content

Instantly share code, notes, and snippets.

@dahlsailrunner
Last active June 18, 2023 05:17
Show Gist options
  • Save dahlsailrunner/254a5d4f0938d30dd4b60f32146a658e to your computer and use it in GitHub Desktop.
Save dahlsailrunner/254a5d4f0938d30dd4b60f32146a658e to your computer and use it in GitHub Desktop.
Notes for working with Hugo on static websites

Hugo is a great platform for static website creation based on Markdown (or HTML) files.

Getting Started

First, install Hugo:

Creating a site

Just run the following command (a directory called quickstart will be created holding your site - replace the name with whatever you want):

hugo new site quickstart

Add a theme

Find themes by searching for Hugo themes -- the "official source" is here: https://themes.gohugo.io/

If you have git installed, the best way to add a theme is by including the theme as a submodule (replace quickstart with whatever you used above and use whatever theme you like):

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

Add content

Creating new pages / posts / etc is usually done with the hugo new command, and can refer to archetypes. Refer to the theme you've chosen for supported archetypes.

hugo new --kind post posts/my-new-post.md

Edit the metadata at the top of the markdown to reflect what you want:

---
title: "My First Post"
date: 2019-03-26T08:47:11+01:00
---

If there is a draft: true value, the page will not be included in the site. Remove that line or set it to false to be able to see the page.

Run the site

From a terminal, run the following command to launch the site:

hugo serve

Then open a browser and go to http://localhost:1313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment