How to list recently edited pages in Hugo

The following snippet will list your Hugo site pages ordered by last modification date. You simply have to reverse it and limit to your liking.



<h2>Recently Edited</h2> {{ $byLastMod := .Site.Pages.ByLastmod }} {{ $recent := ($byLastMod | last 5).Reverse }} <ul> {{ range $recent }} <li> <a href="{{ .Permalink }}">{{ .Title }}</a> </li> {{ end }} </ul>
Code language: HTML, XML (xml)

How to use?

{{< last-edited-pages >}}
Code language: HTML, XML (xml)

About Ricard Torres

Senior Front-end Software Engineer at Netcentric, from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> if you need to.