Display the amount of pages that are on a category page


How to display the amount of pages/articles that are on a category page?

I just want a way to easily and quickly see how many pages are on a category page.

Here you are

<div class="list-of-categories">
  {{ range .Site.Taxonomies.categories.ByCount }}
    <span><a href="{{ .Page.Permalink }}">{{ .Page.Title | upper }}</a>  <sup>{{ .Count }}</sup></span>
  {{ end }}
<ul class="categories">
  {{ range .Site.Taxonomies.categories.ByCount }}
       <a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> <small>({{.Count }})</small>
   {{ end }}

Thank you for your answers.

I use the following solution:

<h1>{{ .Title }}</h1>
<p>{{ printf "%d articles" (len .Pages)}}</p>
{{ range .Pages }}<p><a href="{{ .Permalink }}">{{ .Title }}</a><br>{{ if .Params.date }}<span class="date">{{.Date.Format "02 Jan 2006"}}</span>{{ end }}{{ if .Description }}<br>{{ .Description }}{{ end }}</p><hr>
{{ end -}}

I found this solution here: https://discourse.gohugo.io/t/count-number-of-pages-matching-a-term-in-a-page-of-kind-term-taxonomy-html/35376/2

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.