Specifying datetime in your Hugo posts' front matter

Featured image for sharing metadata for article

Over the last week I've been on holiday, so I've been blogging a fair bit on the stuff I've been working on, which in some cases has resulted in me blogging a couple of times a day.

The trouble is that I currently only tag my posts publish date against the date, not the date+time (datetime). This means that when Hugo is rendering the list of posts, sometimes they'll be in the wrong order of when they were written because Hugo doesn't know that one post was authored after the other (as it's not in the date metadata).

Looking at the Hugo forum post Clarity on front matter date format, it appears that Hugo allows you to specify the datetime in the date field with the ISO 8601 format:

# without timezone offset
date: "2019-03-24T13:43:40"
# with timezone offset
date: "2019-03-24T13:43:40+00:00"

This makes it possible for Hugo to fully understand the datetime that a post was generated.

I've also raised a fix to the Hugo docs to fix it for future users.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #hugo.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.