Creating a list of grouped articles

Hello, I’m write a set of articles as a group or a series. For example:

  • Review Item 1.md
  • Review Item 2.md
  • Review Item 3.md

Now, at the bottom of page for “Review Item 1”, I would like to dynamically list links to the next items in order, "“Review Item 2” and “Review Item 3”. (Note how the current article is not in the list.)

The documentation has me believing that taxonomys are the way to do this so I gave each of these articles the following taxonomy:

Series:
 - The Perfect Foobar

Now the issue is I can’t figure out how to list the articles on the footer of the page for only the series of “The Pefect Foobar”. I couldn’t figure out a way to get this value dynamically to build a range loop and hardcoing the “ThePerfectFoobar” in a range didn’t work either.

    <ul>
      {{ range $name, $item := .Site.Taxonomies.series.theperfectfoobar }}
        {{ $name }}
        <li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a></li>
      {{ end }}
    </ul>

My above range hasn’t yet figure out how to exclude the current article as well. But anyways, am I going down the right path? Any help would be appreciated. Thanks!

front matter:

title = 'Bar 1'
date = 2022-02-15T01:33:56-08:00
draft = false
series = 'bar'

config.toml

[related]
  includeNewer = true
  toLower = true
[[related.indices]]
  name = 'series'
  weight = 100

single.html

{{ $p := sort (site.RegularPages.RelatedIndices . "series") "Date" }}
{{ range $p }}
  <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}

See https://gohugo.io/content-management/related

1 Like

Thank you, this solves my issue! Is tehre a way to to list the current series name? in your example, is there a way to print out “bar” before the range? Thanks!

single.html

{{ .Params.series }}
{{ $p := sort (site.RegularPages.RelatedIndices . "series") "Date" }}
{{ range $p }}
  <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}
1 Like

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