"Related content" Param value

I have two content types: blog and authors

On a blog page I have the authors full name in the front matter, this field is an array

On an authors page I have the authors full name in the front matter

How can I get the the author info from the authors content using a where clause by passing in the full name? Something like this:

{{ $authors := .Param "authors" }}
{{ range $authors }}
     {{ $author := . }}
     {{ range where site.RegularPages "Params.name" $author }}
         {{ .Params.job_title }}
     {{ end }}
{{ end }}
2 Likes

That should work. You can also take the “first” matching page to avoid looping.

{{ range $authorName := .Param "authors" }}
  {{ $authorPage := index (where site.RegularPages "Params.name" $authorName) 0 }}
  {{ $authorPage.Param "job_title" }}
{{ end }}

As an alternative, you could also try defining a taxonomy for authors and defining parameters for each one within the taxonomies page (or data file). That way you also generate a taxonomy listing page for all authors (ordered by number of articles for example), and taxonomy term page for each author (showing all articles). See here and here.

Just treat authors like tags basically, but define a page for each author in content/authors/author-name/_index.md with front-matter and optional content.

Tomorrow I’m going to work through that more thoroughly to understand it’s implications.

But it’s raised a fundamental observation. During my existence as a programmer everything has been geared towards two goals:

Performance
Readability

I’ve just understood that using a ssg, performance is no longer a criteria. I know that might sound obvious but it’s been the holy grail for so long that it’s taken away one of my legs. One doesn’t need to code the best solution anymore for any other goal than maintainability. Or bragging rights. And where’s the fun in that :slight_smile: