Format .Site.LastChange


I’m using Hugo 0.52 with theme beautifulhugo.
I have this variable .Site.LastChange.Format “January 2, 2006 @ 15:04 MST”
but all I get when the site is generated is “January 1, 0001 @ 00:00 UTC”.

Which file, exactly, do I need to modify, for the .LastChange to be updated?
When I use .PublishDate and the date variable in the page is “2018-12-21T13:15:00+02:00”, the date is generated correctly.


Hi there. Checkout the docs on date formatting and see the examples, they’ll help you accomplish what you need

The formatting works, the problem is that the Site.LastChange variable is empty.

When I remove the date: 2018-12-21T14:23:00+02:00 from, the .Lastmod, .Date, .PublishDate also become empty.

I see what you mean now. I get the same results when testing this locally. What hugo version are you using?

Folks, it works for me.

{{ .Site.LastChange.Format "January 2, 2006 @ 15:04 MST" }}

@bdaniel7 please share a project we can clone and run locally. There may be another issue at play.

Version 0.52.

I’ll try to post the project later this evening.
But I did try to modify all files in the site, just to be sure.

I would start a new project, with just a few pieces of content. That’s how we debug everything, actually: make a small project to test something, if it works, it is an issue elsewhere. :slight_smile:

What output did you get?

For reference, here’s what I did to test:

  1. Create new hugo site
  2. Create index content with hugo new, which contains:
title: ""
date: 2018-12-21T10:56:08-06:00
draft: true

  1. Create layouts/index.html, which contains:
{{ .Site.LastChange.Format "Jan 2, 2006" }}
  1. Run hugo -D then inspect public/index.html

I expected to get Dec 21, 2018, but I got Jan 1, 0001

The one I expected (I know, but I already scrapped the example). I added a piece of content and the date updated.

I put mine on the home page. I wonder if the dot context matters (so maybe $.Site.LastChange.Format).

I’ve got a sick kiddo, so multitasking, but if you want to share something for me to clone, I can test. :slight_smile:

I know this may not be intuitive to everyone, but I don’t think a draft updates the LastChange. I mean, it shouldn’t, ne? :slight_smile:

I get the same result even when setting draft to false :frowning_face:

Throw your test repo up somewhere, so I am using the same files. We’ll check it out.

Sure thing. One minute.


We’ll, it doesn’t work for the home page, apparently. But it works for pages in sections (like posts).

I can’t read go, but I imagine if we look it is calculating that from the page kind, and not necessarily other kinds of content.

I think there may be lots of conditions for this, maybe having to do with drafts, and what a piece of content is. We may need to document it more, but do we think there is an bug here?

Ah, I gotcha.

So the docs are worded like


a string representing the date/time of the most recent change to your site. This string is based on the date variable in the front matter of your content pages.

Wonder if it’s worth mentioning that it doesn’t apply to homepage/index front matter date?

I didn’t realize this started in another thread.

Emphasis mine. I didn’t know this has been answered, but yeah, I suppose since then we have included to other kinds of content.

I think the feature works as expected; I don’t think updating the description for a taxonomy is a change the site visitor is thinking of, so it works. We can just clarify it is the specific page kind that changes the value. :slight_smile:

1 Like