I shouldn’t answer posts if I’m in hurry. Nonetheless, thanks for the clarification. After filtering out all pages of type post we’ve to apply a second filter to remove the current page.
My approach is to use the .UniqueID
variable of each page. It’s unique id for the current page (actually the MD5 hash of the content file’s path). The second filter ranges over all pages and compares the unique id of all blog posts with the unique id of the current page. If the unique ids aren’t equal we include them the $filteredPosts
.
{{ $filteredPosts := where (where .Site.Pages "Type" "blog") "UniqueID" "!= ".UniqueID }}
{{ $relatedPosts := shuffle $filteredPosts | first 3 }}