Get .Page.Params from within .Pages

Here is my code for my category taxonomy page:

{{ define "main" }}

<h2>Questions About {{ .Title }}</h2> (<-- Category Title, works as intended)
  {{ range .Pages }}

    {{ if gt .ReadingTime 1 }}
        {{ .Scratch.Set "readingTime" "minutes" }}
    {{ else }}
        {{ .Scratch.Set "readingTime" "minute" }}
    {{ end }}

    {{ $image := .Params.feature }} (<-- Grab the featured image from specific page front matter, does not work)
    {{ $image = resources.Get $image }}

    {{ $author := index .Site.Data.authors }} (<- Grab the author from front matter, does not work)

    {{- $avatar := $author.avatar | default "/images/authors/default.png" -}}
    {{- $avatar = ((resources.Get $avatar).Resize "150x150 webp q65") -}}

[ ... ]

How do I get front matter from the various pages in a category to get called correctly here?

Didn’t find problem of your codes, it should work as expected, unless you’ve change the context (the dot .), such as using these code snippets within the with directive, or typos?



Yeah, like my other issue it was a file pathing thing.

I should do this stuff when I’m tired lol

You mean not tired… you shouldn’t post on forums either it seems :wink:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.