Related content within the current section

I’m trying to limit the “Related Content” to the current section: “articles”. I have several sections (e.g. articles, course, podcast, newsletter, work, etc), and content from those sections are being included when I use this at the end of my “articles” template:

{{ $related := .Site.Pages.Related . }}
{{ with $related }}
  {{ range . | first 4 }}

From what I gather, RelatedIndices would get me there, but it would require keying off of something within the Frontmatter. I’d prefer to key off of the Section, but I’m not sure how to do that, or if it is even possible.

I ran into a similar situation with my RSS feed (limiting the feed to just the Articles). I was able to solve this by limiting the range like:

{{ range (where .Site.Pages ".Section" "articles") }}

Thanks for any pointers you might be able to provide!

{{ $related := .CurrentSection.Pages.Related . }}

config.toml (example based solely on tags)

  includeNewer = true
  name = 'tags'
  weight = 100
1 Like

Thank you, @jmooring ! I was way overthinking it!

{{ $related := .CurrentSection.Pages.Related . }}

That worked perfectly!

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