Clarity on front matter date format

I’ve seen a couple of topics on date formatting, but I’m a little confused as to what I can do. For background, I am using Hugo 0.14.

It seems that I cannot have a date in the front matter (using TOML) in the form of “YYYY-MM-DD” because it does not get translated correctly? Or is that incorrect?

I was going off of the date format function mentioned in the documentation.

I’ve noticed that dates are wrong in strange ways on my generated site.

In my gallery (created from the front matter of pages in a section), the date that appears when highlighting is wrong. The date for all 2014 images has the day set to 14 while the date for all 2015 images has the day set to 15. The day of the week is also off (as you can see below where the same day has different day of the week).

In another section (for posts), the same date is shown multiple times while the front matter has a different date for each entry.

I’m using code like {{ .Date.Format "Mon Jan 06, 2006" }} and {{ $date := dateFormat "Mon Jan 2, 2006" .Date }} in my theme. I’m not sure if one has a different effect than the other, but both appear to have issues with the way I’ve specified my date in the front matter.

My unfinished theme can be found here:
My site that is using the theme can be found here:
I’m currently excluding the themes directory until I finish the theme (so I can have a git submodule pointing to it). If anyone wants to verify what I’m encountering, just create the themes directory and a soft link to the grid side theme.

I’m specifying date in my yaml frontmatter like this -

date: 2015-09-11T15:20:15+09:00

… and referencing it like this -

{{ .Date.Format "Mon, 2 Jan, 2006" }}

The comma after the Mon might be the trick.

Thanks for the suggestion, @RickCogley! Unfortunately, adding the comma didn’t help. I wonder if I have to provide the full date in the format like you have. I’m hoping that I don’t since several of my posts and pictures do not have a specific time attached (so I would have to add a default one everywhere).

I’m hoping that I won’t have to touch my front matter considering the fact that the Hugo documentation has a TOML example that just provides the day, month, and year in the format YYYY-MM-DD.


I’ve even gone in and appended T00:00:00-05:00 to dates in my post section to see if that fixed anything, and it didn’t. The three dates shown in the picture are all listed as July 15th instead of the associated dates.

Looking at your repo, just noticed you have "Mon Jan 06, 2006" as the Format, but I think that 06 is incorrect.

@RickCogley, that was absolutely it! I had two locations where I was using "Mon Jan 06, 2006" instead of "Mon Jan 02, 2006" and one where it was correct. That’s what happens when it gets late, I guess. :wink:

That also explains why I had July 15th for the top three blog posts (I just thought it was copying the first post’s date).

Thanks so much!

1 Like

my pleasure