How to access the last (most recent) page?

Hello everyone

Is there a way to point to the latest page on my site (that is the page which has the most recent date)? I would then want to extract some information from it, something along the lines of .MostRecent.Content

Is this possible?

I would need to know if you’re talking about in a section, taxonomy, or just the site overall. But first look at ordering by the lastmod field:

https://hugodocs.info/templates/lists/#by-last-modified-date

And then use the first func.

1 Like

Thank you, this is exactly what I was looking for. The code

{{ range first 1 .Data.Pages.ByDate.Reverse }}
    {{ .Content }}
{{ end }}

gave me the first page, chronologically speaking (= the most recent by date)

1 Like