Customize Related Content

Two questions:

  1. Is it possible to change the configuration of Related Content for a specific section, posts, and have the default configuration for all other sections?

  2. With the following front matter params:

    company = “Apple”
    keywords = [“iPhone”, “Macbook”]
    locations = [“San Francisco”, “New York”]
    suppliers = [“Acme Ltd”]

I would like to use the Related Content function to use all these parameters as indices, not just .Keywords.

If this is not possible, can I somehow modify .Keywords so it includes all the front matter params listed above so when I use the Related Content function

keywords = ["Apple", "iPhone", "Macbook", "San Francisco", "New York", "Acme Ltd"]

This is the Related Content function from the docs I’m using.

{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }}
{{ range . }}
{{ .Title }}
{{ end }}
{{ end }}

There isn’t a “config per section”.

What you can do is, however, is to create index definitions for all of your keywords (company, keywords, locations, suppliers) and that would work just fine even if one index isnt’t relevant for a section. You can even search in a specific index if you want …

related:
  threshold: 80
  includeNewer: false
  toLower: false
  indices:
  - name: keywords
    weight: 100
  - name: company
    weight: 100
  - name: locations
    weight: 100
  - name: suppliers
    weight: 100
  - name: date
    weight: 10

The weights may be adjusted to match their importance …

1 Like