Rendering lastmod date

#1

I am running into an issue rendering a website using hugo server and was wondering if anyone has helpful insights.

I have this template in _default/single.html

<i class=‘fas fa-calendar’></i> {{ .Page.Lastmod.Format “02/01/2006” }}

and the following front matter:

title = "Standard dir structure for VDEC data analysis projects"
date = 2018-08-25T13:06:25-05:00
weight = 5
lastmod = [":fileModTime", ":default"]

but it always prints the date as in the front matter (2018-08-25) instead of today’s date (I modified the content file today).
if I remove date = 2018-08-25T13:06:25-05:00 from the front matter, it prints an empty date
01/01/0001

what am I missing?

Hugo Static Site Generator v0.47.1/extended darwin/amd64 BuildDate: unknown
update:
same issue with
Hugo Static Site Generator v0.48/extended darwin/amd64 BuildDate: unknown

#2

Please review Requesting Help and share a repo with your site’s project. Then folks can test your issue without building a test site.

#3

I don’t think this is the ISO friendly version Hugo needs.

When referencing in your templates, see .Lastmod here:

Other than that, yes, we need more source to help you out.

#4

The above belongs in config.toml, see https://gohugo.io/getting-started/configuration/#configure-front-matter

1 Like
#5

Thanks bep,
makes sense,
so lastmode in the front matter is to hardcode the date?!

#6

In a sense. I have written much about this in the past: Using the file mod timestamp will only work if you have one source. Once you distribute this across machines, that timestamp will not represent “author date”. Have a look a the Git integration Hugo provides.