I’m trying to sort my taxonomy page for tags by how many pages each tag has.
To do that, I’m using {{ range .ByCount }}
(I also tried .Pages.ByCount). However, even though the docs and everything I’ve read online seems to indicate that this should work, I’m getting the error:
ERROR render of "term" failed: "…/blog/layouts/_default/list.html:3:9": execute of template failed: template: _default/list.html:3:9: executing "main" at <.ByCount>: can't evaluate field ByCount in type *hugolib.pageState
ERROR render of "section" failed: "…/blog/layouts/_default/list.html:3:9": execute of template failed: template: _default/list.html:3:9: executing "main" at <.ByCount>: can't evaluate field ByCount in type *hugolib.pageState
ERROR Rebuild failed: render: failed to render pages: render of "taxonomy" failed: "…/blog/layouts/_default/list.html:3:9": execute of template failed at <.ByCount>: can’t evaluate field ByCount in type page.Page
(edited to remove identifying information from the path).
The code for the template in question is as follows:
{{ define "main" }}
<h1>{{ if not (eq (i18n .Title) "") }}{{ i18n .Title }}{{ else }}{{ .Title }}{{ end }}</h1>
{{ range .ByCount }}
<div class="entry">
<a class="coverlink" href="{{ .RelPermalink }}"><span class="linkcover"></span></a>
<span class="inline-flex space-between mobile-flex-column">
<a class="post-title" href="{{ .RelPermalink }}">
{{ .Title }}
</a>
<span class="horizontal-spacing"></span>
{{ partial "metadata.html" . }}
</span>
{{ if (isset .Params "description") }}
<div class="entry-description">
{{ .Params.Description }}
</div>
{{ else }}
{{ with .Summary }}
<div class="entry-summary">
{{ . }}
</div>
{{ end }}
{{ end }}
</div>
{{ end }}
{{ end }}
Any help would be greatly appreciated, I have no idea why this isn’t working.