Load multiple markdown contents on single page using custom md variables

Hello everyone,

I have a problem with loading markdown content on a single page coming from two or few different *.md files. There is a similar answer on Web - but it solves that problem using specific variable TYPE.

What I want to achieve is to have POST markdown coming from /post/abc.md and to have separated *.md files (/authors/john-doe.md) responsible for AUTHORS description. Author description should appear at the bottom of the page.

I want to use sth like below:

{{range where .Site.Pages "Author" "=" "John Doe"}} 
{{ .Content }} 
{{ end }}

How to run this type of range using custom markdown variables like Author??

Are you asking how to put author information in the bottom of a layout for a single page with author: Jon Doe in your post front matter? And you’re not using authors as a taxonomy, correct?

Assuming your source is organized as follows…

content/
|
|---authors/
|
|---posts/

In your layout/posts/single.html, you could use something like the following, assuming that each content .md under authors treats title: in the front matter as the author’s full name.

{{$author := .Params.author}}
{{range where .Site.Pages "Section" "authors"}}
  {{if eq .Title $author}}
    {{.Content}}
  {{end}}
{{end}}
1 Like