I want to query if I am in list.html in the layout

I want to query whether I have list.html in the head.html file with the if structure, accordingly I will add a special css code to that page.

How can I do this?

You need to elaborate this a bit more as it is hard to understand what you want to achieve.

You can’t quite do that.

In

and

a collaborator and I are trying to get page-specific styles (in our case base64 low quality images or color gradients, to use as LQIPs (low quality image placeholders)) into head.html.

It’s a bit tricky, so understanding more of what you have and what you are trying to achieve is important.

1 Like

Set a parameter in the front-matter of your list pages, check for that in your baseofhtml and pass that to head.html.

2 Likes

Do you want to know which template is called, or do you want to know the page .Kind (i.e., page, section, home, taxonomy, or term)?

If you want to do something based on .Kind, place something like this in your head.html partial:

{{ if eq .Kind "section" }}
  <style>
    body {
      color: red;
    }
  </style>
{{ end }}

Or you could set a body class in baseof.html and target in a stylesheet.

{{ $class := printf "kind-%s" .Kind }}
<body {{ printf "class=%q" $class | safeHTMLAttr }}>

rendered

<body class="kind-section">
2 Likes

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