Blog
Lists in Hugo 0.58
7 September 2019
This is mainly for my own reference, but as of Hugo 0.58 the code for creating a list of pages has changed a bit. This means you need to use
.Site.RegularPages
instead of the old
.Data.Pages
For example, on my homepage I list the first five posts of each type of page. The old way I did this was
{{ range first 5 (where .Data.Pages "Type" "post") }}
<a href="{{ .Permalink }}"><p>{{ .Title | markdownify }}</p><hr><p>{{
$wordcount := countwords .Content}}{{$wordcount}}</p></a>
{{ end }}
In 0.58 that didn’t work, so I had to change it to
{{ range first 5 (where .Site.RegularPages "Type" "post") }}
<a href="{{ .Permalink }}"><p>{{ .Title | markdownify }}</p><hr><p>{{
$wordcount := countwords .Content}}{{$wordcount}}</p></a>
{{ end }}
So now you know, and knowing is half the battle.