Related posts by nested section

I tried a solution in this forum, specifically the part below, but it does not work for nested sections e.g. content/docs/guides. How do I make it work without relying on front matter entries? cc @jmooring

{{ range where (where site.RegularPages "Section" .Section) "Permalink" "ne" .Permalink }}
  <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}

You may want to describe what you want to happen. That’s not obvious to me.

1 Like

From my tests, the code above limits therelated posts to the same section and omits other sections. It works when the posts are in sections, but the posts are not limited to the section they are in when in nested section.