Absolutely minimal Hugo static site

Published: Monday, Sep 28, 2020 Last modified: Thursday, Dec 3, 2020

I prefer this over the https://gohugo.io/getting-started/quick-start/ which asks you to download a heavyweight/complex theme!

This currently works in Hugo Static Site Generator v0.75.1/extended:

hugo new site minimal
cd minimal
echo "<h1>Hello World</h1>" > layouts/index.html
hugo --disableKinds=taxonomy,taxonomyTerm,RSS,sitemap

Notice you require a layouts file, and look up order is quite complex!

Markdown (with .md suffix) goes into the content/ directory, and you need to modify your layout template to show that content, like so:

echo -e "<h1>layouts</h1>\n{{ .Content }}" > layouts/index.html
echo "# content" > content/_index.md

However _index.md only works on the index and has special properties that cause confusion. For a more generic solution you need to create layouts/_default/single.html:

hugo new site ${1:-"testing"}
cd ${1:-"testing"}
mkdir layouts/_default
echo -e "<h1>Hello from layouts</h1>\n{{ .Content }}" > layouts/_default/single.html
echo "# Hello from index" > content/index.md
hugo --disableKinds=taxonomy,taxonomyTerm,RSS,sitemap

Note in many cases your Markdown in Hugo requires Frontmatter. So just bear that in mind when creating more markdown posts.

To create content at an arbitary path like /foo/, use this pattern:

hugo new site ${1:-"testing"}
cd ${1:-"testing"}
mkdir layouts/_default
echo -e "<h1>Hello from layouts</h1>\n{{ .Content }}" > layouts/_default/single.html
mkdir content/foo
echo "# Hello from foo" > content/foo/index.md
hugo --disableKinds=taxonomy,taxonomyTerm,RSS,sitemap