Hugo

How to hide posts without a category?

I have a micro.blog website with a Hugo theme and right now I have figured out how to hide posts with certain categories, but the problem is that my posts don’t have default categories, so if I post something without specifying the category it doesn’t get parsed through the parameters I have set.

here’s what I have right now:

{{ $paginator := .Paginate (where .Pages "Type" "post") }}
{{ range $paginator.Pages }}
{{ if and (not (in .Params.categories "micro")) (not (in .Params.categories "none")) }}
{{ .Render "summary" }}

I am at a loss of what I need to add to have it not show any posts that have zero categories.

To not show posts without categories, I would expect the following (untested) to work:

{{ $paginator := where .Pages "Params.categories" "!=" nil }}
1 Like