Is there any way to have frontmatter metadata for homepage?

Since the homepage is handled differently from other site content it appears there’s no way to include homepage specific metadata as frontmatter.

My use case is to maintain a ‘Last updated’ variable in the frontmatter, which is displayed in the footer of each page. I wrote a short node script that automatically injects the current date into the frontmatter of content pages when the file (any .md or .html file in site/content/) is saved. The ‘last updated’ information isn’t necessarily a good fit for .Site.Params because it applies only to the homepage.

I suppose I can write another script that injects the date directly into the footer of the homepage, but surely my use case isn’t the only one for needing homepage metadata.

Hugo already provides a variable that stores the last modification date of the document that is used to build a page:

This page was last modified at {{ .Lastmod }}

I added the following to my template {{ .Lastmod.Format "2006-01-02" }}, which yeilds 0001-01-01.

Do I need to tell hugo where I am (timezone?) to get an accurate time?

I found your script in this thread. After having a look at the corresponding issue it seems to default to the date value in the frontmatter and you’ve to overwrite it with the lastmod manually.

Since a content change of a file doesn’t affect lastmod I wouldn’t know how to access the last real modification date inside a template.

@rhewitt Are you trying to do this at the page-level? If it’s across the site, see the thread here that @bep helped me with a short while back:

@rdwatters

Yes, I’m trying to achieve this on a page-by-page basis (when was the content edited last rather than when was the site built last).