Other posts in the same series listed at bottom of post

I feel like I’m missing something pretty obvious, but I’ve searched and read quite a bit and have still not been successful. I want every post that uses a “series” taxonomy to list all other posts in the series at the end of that post.

Something like this: image

I tried to do the following, which seems as if it should produce exactly what I want: https://npf.io/2014/08/making-it-a-series/ .

I’ve also tried to use the method described here, but I suspect I simply don’t understand it. When I include {{ $related := .Site.RegularPages.Related . }} in my single.html, I get an error claiming that the “:=” is unexpected.

What should I try?

Here’s my code: https://github.com/valzi/light-transmuter

You need to configure your related content if you want to use the .Related feature. It is in the docs you link to here: Related content | Hugo

You need to configure the related indices, as series is not one of the default indices used. So you probably need to add something like the following to your config.toml (or whatever the relevant values) :

[related]
  threshold = 80
  includeNewer = false
  toLower = false
  [[related.indices]]
    name = "series"
    weight = 10

What Hugo version are you using?

0.54.

I’ll give your code a try. I did something like that, but yours looks different than what I remember typing.

I tried your code. I no longer get an error, but the related content is also not displaying at the end of the post.

I’m using Hugo 0.54.

Here’s a sample post.

I’ll try to include all relevant code here:

from config.toml:

  [related]
  threshold = 80
  includeNewer = false
  toLower = false
  [[related.indices]]
    name = "series"
    weight = 10

From layouts/_default/single.html

{{ $related := .Site.RegularPages.Related . }}

and here is layouts/partials/related.html

{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }}
<h3>See Also</h3>
<ul>
	{{ range . }}
	<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
	{{ end }}
</ul>
{{ end }}

Your single.html is not calling your related partial, so it is not being rendered.

Either put the contents of the related partial into the single.html layout, or call the partial.

{{ $related := .Site.RegularPages.Related . | first 5 }}
    ^  This bit gets the related pages 
    v  This bit prints out the related pages, if there are any
{{ with $related }}
<h3>See Also</h3>
<ul>
	{{ range . }}
	<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
	{{ end }}
</ul>
{{ end }}
1 Like

Wow, dumb mistake. Fixed it! Thanks a lot.