Tried several different range implementations in my homepage _index.md but all are just rendering the code instead of executing the function:
{{ range ( first 3 ( where .Site.Pages "Type" "blog" ).ByDate ) }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
and
{{- range ( where site.RegularPages "Section" "blog" | first 3 ) }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
With no luck.
What’s the path to your index.html file?
{{ range ( where $.Site.Pages.ByDate "Section" "blog" ) | first 3 }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
sorry, mistyped above, but I have “_index.md” located at root/content/_index.md
You’ve placed template code in a content file. You can’t do that.
Ended up making it as a shortcode instead:
{{ $blog_pages := where .Site.RegularPages "Section" "==" "blog" }}
<h3>Latest from the Blog</h3>
<ul>
{{ range first 3 $blog_pages }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>