_index.md not showing up in related content

Hi everyone,

I’m working on configuring the Related Content feature in my Hugo project, and I’m running into an issue where some expected related items aren’t being shown.

Content Structure

/content/
  /cat1/
    /cat1-abc/
      /index.md  => tags: ["tech"]
  /cat2/
    /cat2-abc/
      /index.md
    /cat2-xyz/
      /index.md
    _index.md => tags: ["tech"]
  /cat3/
    /cat3-abc/
      /index.md => tags: ["tech"]

Partial Template (simplified)

    {{ with site.RegularPages.Related . | first 5 }}
      <ul>
        {{ range . }}
          <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
        {{ end }}
      </ul>
    {{ end }}

config.toml Related Content Settings

[related]
  includeNewer = true 
  threshold = 80
  toLower = false
  [[related.indices]]
    applyFilter = false
    cardinalityThreshold = 0
    name = 'tags'
    pattern = ''
    toLower = false
    type = 'basic'
    weight = 100

Current Behavior:

When I visit /cat1-abc/, the related content looks like this:

  • Cat3 Abc

Desired Behavior:

I want the related content to look like this:

  • Cat2
  • Cat3 Abc

The Issue:

I can’t figure out why the pages for /cat1-abc/ and /cat3-abc/ show up in the related content successfully, but /cat2/ is always missing, even though they all share the same tag (["tech"]). Specifically, I’m wondering if the _index.md pages are being ignored when generating related content.

How can I ensure that the _index.md pages (like /cat2/_index.md) are included in the related content for their respective sections?

Thanks in advance for any help!

educated guess:

your cat2 is a section, so no regular page.

use site.Pages.Related

1 Like