Access single page tags within {{ range .Pages }}

On list pages outside of my index.html page, I try to access a specific tag theme, specified in the metadata of the markdown-page. Based on this theme-tag, I create an <article> with a class (e.g. <article class=themeVariant-blue> for theme=blue.

On the index.html, I achieved this behavior using pagination:

{{ $pages := .Site.RegularPages }}
    {{ $paginator := .Paginate (where $pages "Params.type" "ne" "ordinary") }}
      {{ range $paginator.Pages }}
        <article {{ with .Param "themeVariant" }} class="card themeVariant-{{ . }}" {{ end }}>
<p> content </p>
        </article>
      {{ end }}

In action it does look like that. The class defines the shadow of the card.

My list.html currently contains of something like that:

    {{ range .Pages }}
      <article class="card themeVariant-default">
      </article>
    {{- end -}}

I cannot just copy the code from my index-page is it cannot access that page-variables this way.

Thanks for reading,
help would be very appreciated.

– Luca

Hello @lucaschulz.xyz

You can try this

{{ range .RegularPages }}
     <article class="card themeVariant-{{ with .Params.themeVariant }}{{.}}{{else}}default{{end}}">
     </article>
{{- end -}}
1 Like

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