'How to filter post by category in Hugo

how to filter post in Hugo by category taxonomy I am having three main category like web, Linux and networking and i want to display recent 3 post of the category. Please someone tell me how to do that.



Solution 1:[1]

Last 3 posts from 3 categories

{{ $p := where site.RegularPages "Type" "posts" }}
{{ $p = where $p "Params.categories" "intersect" (slice "web" "Linux" "networking" }}

{{ range first 3 $p }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}

Source: https://discourse.gohugo.io/t/list-down-posts-from-multiple-categories/36701

Last 3 posts from 1 category

{{ $p := where site.RegularPages "Type" "posts" }}
{{ $p = where $p "Params.categories" "intersect" (slice "web") }}

{{ range first 3 $p }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}

Source: https://discourse.gohugo.io/t/show-posts-by-category-not-working/33690

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mr. Hugo