Iterate N items excluding first from Pages in template

19 views
Skip to first unread message

Ravi Kumar

unread,
Mar 18, 2016, 11:26:19 AM3/18/16
to Hugo Discuss
How I can generate the list of articles, from 2nd to 5th.

Here is what I tried - 

{{ range first 4 (where .Data.Pages "Section" "article") }}
{{ range after 1 . }}
{{ printf "%+v" . }}
{{ $article := . }}
{{ $article.Content }}
{{ end }}
{{ end }}

But its throwing error - ERROR: 2016/03/18 Error while rendering homepage: template: index.html:65:25: executing "index.html" at <after 1 .>: error calling after: can't iterate over *hugolib.Page

Ravi Kumar

unread,
Mar 18, 2016, 11:49:17 AM3/18/16
to Hugo Discuss
Got working code here - https://discuss.gohugo.io/t/iterate-n-items-excluding-first-from-pages-in-template/2943


{{ range after 1 (first 5 (where .Data.Pages "Section" "article")) }}
Reply all
Reply to author
Forward
0 new messages