Only list sections/categories

Hi,

I’m still learning Hugo and I’m trying to build my first theme. On my index page, I’m trying to do the following but I’m having trouble:

  1. List pages that have certain categories (or tags) attributed to them in the page’s frontmatter

or

  1. list pages that are in sections that I have identified in a mainSections: param in the config.

Something is tripping me up and I cannot get it to work.

And ideas?

I don’t have a public repo yet.

That’s not helping. Anyway, from my own guesswork

  1. Maybe try intersect
{{ $pages := where .Site.RegularPages "Params.categories" "intersect" (slice "category1" "category2") }}
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
[params]
  mainSections = ["section1","section2"]

There are examples of both in the docs…

https://gohugo.io/functions/collections/where/#intersection-comparison
https://gohugo.io/functions/collections/where/#portable-section-comparison

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.