How best to display "Site last updated" in site footer?

I’ve read that .GitInfo might get me the “last modified” date for the site as a whole, but it sounds like enabling it might mess with already manually-specified dates in articles? I also don’t think Git is in my PATH (due to potential conflicts on Windows).

Is there a variable to get the build date/time for a Hugo site? (without Git)

I’m currently using the following to give me “Site last updated $Date” in my footer (when provided with a URL to a Git Repo or other build log in Site.Params.commit), but now doesn’t get the correct date, always saying my site (theme) was last updated June 2022, despite having a bunch of articles from more recently

 {{ if .Site.Params.commit }}
                Site last updated: <a href="{{ .Site.Params.commit }}" target="_blank">{{ now.Format "06 June 2006" }}</a>
              {{ end }}

PS. For future readers, this thread may also be relevant.

During 2022, this will always display 22 June 2022:

{{ now.Format "06 June 2006"}}

Do this instead:

{{ now.Format "02 January 2006"}}


1 Like

Thank you so much! That fixed it! My site now presents a last modified heartbeat in the footer with the correct date!

Can’t remember where I got the date of 06 June 2006 from - I thought I’d copied it late at night from elsewhere in the code, but unable to locate that, I can only assume that my previous self guessed Hugo required a random but syntactically correct date (I was wrong).

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.