Hello there,
recently started playing around with Hugo and I do really love it. The thing I want to do is to have a list of blog posts with different tags and have a separate page where I show a list of blog posts for a specific tag including a little intro. I am almost there. Thanks to the Congo theme I got a ton of inspiration.
The way I did it is this. I created a branch bundle like this:
content
hot_topic
_index.md
# content/hot_topic/_index.md
---
title: "HOT TOPIC!!!!"
showAuthor: false
showDate: false
showReadingTime: false
---
Generic Description about the topic
---
# 2021
# article 1
# article 2
# etc ..
To customize the list, this is what I came up with:
layouts
hot_topic
list.html
{{ define "main" }}
{{ partial "section-header.html" . }}
{{ $pages := where .Site.RegularPages "Params.tags" "intersect" (slice "hot_topic") }}
{{ if gt $pages 0 }}
<section>
{{ range (.Paginate ($pages.GroupByDate "2006")).PageGroups }}
{{ if $.Params.groupByYear | default ($.Site.Params.list.groupByYear | default true) }}
<h2 class="mt-12 text-2xl font-bold first:mt-8 text-neutral-700 dark:text-neutral-300">
{{ .Key }}
</h2>
<hr class="border-dotted border-neutral-400 w-36" />
{{ end }}
{{ range .Pages }}
{{ partial "article-link.html" . }}
{{ end }}
{{ end }}
</section>
{{ partial "pagination.html" . }}
{{ else }}
<section class="mt-10 prose dark:prose-light">
<p class="py-8 border-t">
<em>{{ i18n "list.no_articles" | emojify }}</em>
</p>
</section>
{{ end }}
{{ end }}
This pretty much gets me where I want (I’m open to suggestions on how to improve this, not quite happy that I’ll have to overwrite the whole list.html …)
I will see the generic description about the topic and after that I see the list of articles related to that topic (defined by the tags in the pages).
The only thing left is: I don’t want to see the generic description on page 2. It’s a minor thing but I feel there is a way to get there.
So is there a way to disable this text on any page after 1?