In the Related Content documentation it says, “List related content: To list up to 5 related pages (which share the same date or keyword parameters) is as simple as including something similar to this partial in your single page template”
However, I am finding that both snippets below only list related if other content date comes before the current page. So “My First Post” actually has no related content.
<!-- snippet 1 -->
{{ $page := . }}
{{ $opts := dict
"indices" (slice "tags" "keywords")
"document" $page
}}
{{ $related := .Site.RegularPages.Related $opts | first 5 }} {{ with $related }}
<h3>See Also</h3>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
<!-- snippet 2-->
{{ $related2 := .Site.RegularPages.Related . | first 5 }}
{{ with $related2 }}
<h3>See Also</h3>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
My intention is to list related content by keywords only for now. I assume user error, what am I missing? Thanks.
Edit: hugo v0.125.1