Change date format

I understand the blog created here is based on Hugo, and I was directed to .Format | Hugo to read on how to change the format to ISO format.

My understanding is that I need to have something like:

{{ .PublishDate.Format "2006-01-02" }} 

to get that to work, but I don’t understand where. I created a custom theme, I see the various different HTML, and I thought I need to look into baseof.html, but I don’t understand where in there I need to tell Hugo to change the date format.

Found the answer.

My theme (paper) uses baseof.html as the main page (I believe this is the first and primary page in Hugo). baseof.html creates a block element called “main”. Main is defined in list.html.

So, both list.html and single.html have {{ .Date | time.Format ":date-medium" }} that creates the date in a Jun 6, 2018 format (per Hugo documentation). This needs to be changed to {{ .Date | time.Format "2006-01-02" }}

What’s the deal with signle.html? That’s the HTML template for the individual article plages - the page of the post that opens once you click on one of the posts in the main page (which is the “list”).

You’ve got it basically right. baseof is the default template for every page, if you want, and every other page can just define the main block to include what’s in baseof as well.

list.html is the template used for collections of posts, no matter where they are or are structured.

single.html is how a single post is rendered.

The list and single concepts are built into Hugo, and allow you to define different pages by content type. Micro.blog posts and pages are all considered a content type of post.

1 Like