Everything I need to complete the authors section I’m building is complete except for producing an author page that contains details about the author followed by a list of the posts made by that author.
- I have the following folders.
\content\authors
\layouts\authors\static\images\authors
- Each author will have a folder under \content\authors and, in that folder, a file named _index.md:
\content\authors\john-smith_index.md
Corresponding images will be in the static folder:
\static\images\authors\john-smith.jpg
- \layouts_default has two files:
author.terms.html
author.html
- In config.toml, my taxonomies are defined as:
[taxonomies]
tag = “tags”
category = “categories”
topic = “topics”
social = “social”
author = “authors”
- In an author’s _index.md folder, the front matter looks like this (simplified for example):
title: “John Smith, Ph.D.”
author: John-Smith
image_name: “taxonomy”
image : “images/authors/john-smith.jpg”
- In each article, the front matter contains (simplified for example:
title: "How to Take a Walk "
author: [“John Smith”]
image : “images/walks/how-to-take-a-walk.jpg”
type: “post”
The Problem:
My authors page works fine and lists all of the authors in a nice format. I’m happy with that.
It successfully links to the author page, as do the author tags on each post.
The author’s page looks good. However, I want a list of that author’s articles at the bottom of the author’s page and I can’t get that working. I’ve looked at every one of the topics here that refer to authors and authors pages and I’ve tried lots of different things but the end result is always the same: no articles listed.
My current attempt in author.html looks like this:
{{ $author := .Params.author }}
<h2>Articles by {{ $author }} </h2>
{{ range .Site.RegularPages }}
{{- range where .Site.Pages "Params.authors" "intersect" (slice $author) -}}
<p>{{ .Params.title }} </p>
<p> this is an article </p>
{{- end -}}
{{ end -}}
It prints the title correctly. It currently says “Articles by John-Smith” because I wanted to see what value was being placed in $author. Earlier, I used the title from the author _index.md and that worked just fine.
I added the “
this is an article
” line just to know if the loop was actually looping through anything. The answer is nope.I have a feeling that this a really stupid error with a simple fix but, for the life of me, I don’t see it.
Thanks in advance for any help.
Brian