The following code does what I need, i.e. count the number of posts with a given term (e.g.: category=css) before listing those posts. I am on page of kind=term in layouts/_default/taxonomy.html.
#**Run in: layouts/_default/taxonomy.html of .Kind=term**
#.Title=term (e.g.: css); .Section=taxonomy name (e.g.: blog/categories)
{{$term := .Title}}
{{$taxo := .Section}}
{{ range $taxonomy_term, $taxonomy := .Site.Taxonomies }}
{{ if eq $taxonomy_term $taxo}}
{{ with $.Site.GetPage (printf "/%s" $taxonomy_term) }}
<p>taxonomy_term:{{ $taxonomy_term }}</p>
{{ range $key, $value := $taxonomy }}
{{ if eq $key $term}}
<p>key:{{ $key }}</p>
<p>len_key:{{len $value}}</p>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
Is there a more elegant and sustainable way of achieving the same result? I am only interested in len
or Count
.