How do I show 3 'random' posts without showing the current post?

So, I’m trying to list 3 posts on the bottom of each post page. But, I don’t want to include the current page. How do I do that?

This is what I have now:
{{ range first 3 (shuffle (where .Site.RegularPages "Section" "blog")) }}

You are looking for https://gohugo.io/content-management/related/. :slight_smile:

Yes related with no configuration should do exactly what you want.

Otherwise you wrap your where clause in another one to exclude the current post:

{{ range first 3 (shuffle (where (where .Site.RegularPages "Section" "blog") "Title" "!=" .Title )) }}
1 Like