Make blogs _index.md front matter use the date of the most recent blog

I have a homepage which ranges through all the pages in my content directory by date which is nice. However, lists are a bit tricky, as unlike just single pages, lists involve many pages and thus many dates. I have a folder named blogs, which is a list which contains pages of my blogs. I would like the front matter of my blogs folder to use the date of the most recent blog.

content>blog:

blog 1.md (Front mater Date: Jan 1)
blog 2.md (Front mater Date: Jan 2)
_index.md (Front mater Date: use the date of the most recent most, therefore this should use blog 2.md's date. And then if I add blog3.md (Date: Jan 3), it should then use blog3.md's date.)

SOLUTION: Realized that if I just leave the _index.md’s date front matter empty it will be automatically populated by the most recent date among the posts within the folder

layouts/posts/list.html

{{ with (index (.Pages.ByDate.Reverse) 0).Date }}
  <p>Last updated: {{ . | time.Format ":date_full" }}</p>
{{ end }}
2 Likes