Get a list page in a nested section, consisting of tags from the blog section

I don’t quite have the programming chops, but I have been using Hugo quite a while now.

This is the structure of my contents folder

├── blog (lots and lots and lots of posts)
├── more
│   ├──
│   └──
├── projects
│   ├──
│   └── other-projects
│       └──
├── reading

What I am struggling to do, is create a list in the other-projects folder, of posts tagged other-projects in my blog folder.

Been looking all day, and am thoroughly confused.

If any one could help, or point me somewhere, I’d be really grateful


title = 'Other projects'
date = 2024-01-08T10:51:03-08:00
draft = false
layout = 'blogs-tagged-other-projects'


{{ define "main" }}
  <h1>{{ .Title }}</h1>
  {{ .Content }}
  {{ $p := where site.RegularPages "Section" "blog" }}
  {{ $p = where $p "Params.tags" "intersect" (slice "other-projects") }}
  {{ range $p }}
    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
  {{ end }}
{{ end }}

1 Like

You’re godsent @jmooring!

It worked!

The missing piece for me was understanding a layout was needed and where to put it.
(I found various examples of ranging and I was somehow trying to get it to work by making a shortcode that would put in html into my

The way you showed it, makes so much more sense.

Thank you so much, once again :slight_smile:

1 Like

Update: I got it to look just the way I wanted.
From what you taught me, and the links you pointed me to, I figured I could reuse my theme’s list layout for my custom list too.

So I used that as my layouts/_default/blogs-tagged-other-projects.html and dropped your range code, in there.

Thank you so much once again, @jmooring!

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