Display 3 most recent blog posts (but not other pages)

I have a site with a bunch of static pages, plus a blog.

On the front page, I’d like to create short links to the three most recent blog posts (but not to any possibly recently modified static page). The blog posts are all in directory blog/ .

I’m failing to figure out the syntax for this. So far, I have:

{{- range (.Paginate ( first 3 .Pages.ByDate )).Pages }}
    <li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{- end}}

but I need to also filter by directory blog/ . This is in my layouts/index.html template. How do I do this?

(P.S. Where is the best description how this language works? I can’t even parse how the above statement functions…)

1 Like

Se https://gohugo.io/functions/where/#readout

E.g. something ala this mouthful:

{- range (.Paginate ( where site.RegularPages "Section" "blog" | first 3 ) )).Pages }}

But paginating 3 pages may not make much sense.

2 Likes

For the next guy or gal: without the pagination, it is something like:

{{- range ( where site.RegularPages "Section" "blog" | first 3 ) }}
7 Likes