How to create a page that groups post for tags

I want to create a page that collects all the posts with the same tag (f.i.: ‘newsletter’).
What do you suggest to do?
The theme I use is PaperMod.
Moreover, I would like an RSS feed related to that page.
I already have an RSS feed, but it’s related to the entire website.
Is it possible to generate an RSS feed for a single page?

Build a template for your tags that lists only the posts having hewsletter in their tags.

You’ll probably find some hints in the documentation and discussions here in the forum.

Indeed, I would need help in creating the template :slight_smile:

hugo new newsletter/_index.md
mkdir layouts/newsletter/
touch layouts/newsletter/list.html

layouts/newsletter/list.html

{{ define "main" }}
  <h1>{{ .Title }}</h1>
  {{ .Content }}
  {{ $p := where site.RegularPages "Type" "posts" }}
  {{ range where $p "Params.tags" "intersect" (slice "newsletter") }}
    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
  {{ end }}
{{ end }}
1 Like

Thank you very much @jmooring.
I appreciate it very much.
The structure of my website is the following:

content
├── en
│   ├── _index.md
│   ├── pages
│   ├── posts
├── it
│   ├── _index.md
│   ├── pages
│   ├── posts

If I understand well, I should create a folder (newsletter) for each language folder.
Is it so?
I intend to collect all the posts with the tag newsletter on a single page.
Is the layout/nesletter/list.html valid for all?

Yes

Yes

Thank you again.
Two last questions:

  1. the _index.md should be empty?
  2. Can an RSS feed be created for the specific page or tag?

The _index.md file can contain whatever you want, but I would give it a title at minimum.

+++
title = 'Newsletter'
date = 2024-07-13T09:47:43-07:00
draft = false
+++

It’s a section page, so an RSS feed is created automatically.

Try it:

git clone --single-branch -b hugo-forum-topic-50679 https://github.com/jmooring/hugo-testing hugo-forum-topic-50679
cd hugo-forum-topic-50679
hugo server

It doesn’t work.
The page is empty.
The structure is the following:

content/
├── en
│   ├── _index.md
│   ├── pages
│   ├── posts
│   └── xmpp
│       └── index.md
├── it
│   ├── _index.md
│   ├── pages
│   ├── posts
│   └── xmpp
│       └── index.md

Yes, it does. See the example I provided in my previous reply.

Probably, I found the issue.
The tag I used for the posts I am interested in collecting on one page is “newsletter-xmpp.”
If I remove -xmpp and leave only the newsletter, I will see the post on one page.
Is there any limit to the slug used for the tags?

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