If I use {{ partial "recentposts" }}
in layouts/index.html
, I get this error:
Template changed "/home/rea/works/theblog/layouts/index.html": CREATE
ERROR 2017/12/06 12:48:35 Error while rendering "home": template: index.html:26:3: executing "index.html" at <partial "recentposts">: error calling partial: template: partials/recentposts.html:13:48: executing "partials/recentposts.html" at <where .Site.RegularP...>: error calling where: can't iterate over <nil>
And this is contents of the partial/recentposts.html
file:
{{ range first 4 (where (where .Site.RegularPages "Section" "blog") "Params.show" "true") }}
<h4><a href="{{ .Permalink }}" title="">{{ .Title }}</a></h4>
{{ .Summary }}
{{ end }}
If I put the recentposts.html
contents directly whitin index.html, it works well! Why the ‘partial ing’ leads to the error?