Ronalds Vilciņš

Count the pages in a Hugo section

If you need to show how many pages belong to a Hugo section, filter .Site.RegularPages by its Section value and pass the result to len:

<p>Total number of pages in the /articles/ section:
	{{ len (where .Site.RegularPages "Section" "==" "articles") }}.
</p>

Using .Site.RegularPages keeps section pages and other list pages out of the count. Replace articles with the name of the section you want to measure.

Enjoyed reading this?

If you found this article helpful, consider supporting my writing. Every little bit helps keep this blog going.

← Back to all articles