I use Go professionally, and I like using it for my personal projects too (I still ❤️ you Python). Hunting down a Go based content management system seemed natural, while I also believe in static sites for simple marketing sites.

So I choose Hugo.

I find Hugo really simple to use, templating is very familiar, and it allows me to deploy a very secure site to an S3 or GCS bucket. A fast and cheap pattern I have now implemented on many high volume sites.

About Hugo

Hugo is a fast and modern static site generator written in Go, and designed to make website creation fun again.

Hugo is a general-purpose website framework. Technically speaking, Hugo is a static site generator. Unlike systems that dynamically build a page with each visitor request, Hugo builds pages when you create or update your content. Since websites are viewed far more often than they are edited, Hugo is designed to provide an optimal viewing experience for your website’s end users and an ideal writing experience for website authors.

Websites built with Hugo are extremely fast and secure. Hugo sites can be hosted anywhere, including Netlify, Heroku, GoDaddy, DreamHost, GitHub Pages, GitLab Pages, Surge, Aerobatic, Firebase, Google Cloud Storage, Amazon S3, Rackspace, Azure, and CloudFront and work well with CDNs. Hugo sites run without the need for a database or dependencies on expensive runtimes like Ruby, Python, or PHP.

Taken from What is Hugo.

Accessing Dates in a Hugo Template

The two ways I would normally access publish date and last modified date:

  1. Editor controlled via front-matter in Markdown.
  2. Automatically extracted from git.

front-matter

Front matter allows you to keep metadata attached to an instance of a content type—i.e., embedded inside a content file—and is one of the many features that gives Hugo its strength.

You can manually define your dates in the front-matter and access it in your template:

Add something like the below to your front-matter:

date: "2021-03-30"
lastmod: "2021-03-31"

Then in your layout template you can access it:

{{ $date := .Date.Format "02.01.2006" }}
{{ $lastmod := .Lastmod.Format "02.01.2006" }}

<p>Published on: {{ $date }}</p>
<p>Edited on: {{ $lastmod }}</p>

git

Automation is generally better than manual. So let’s get these dates from git.

First enable git info in your config.toml file:

enableGitInfo = true

Configure front-matter as per Hugo documentation with git as a date source:

[frontmatter]
date = ["date", "publishDate", "lastmod"]
lastmod = ["lastmod", ":git", "date", "publishDate"]

By default, :git comes before lastmod but the configuration change above allows you to still define lastmod in your front-matter to override git derived dates if you wish.

You can now display lastmod:

<p>Last Modified: {{ .Lastmod.Format "2 January 2006" }}</p>