What's wrong with my code? telling Hugo if a section has regular pages then add this partial not working

Hi there,

in the partial/head.html I have this condition

{{ if .Site.HasRegularPages "Section" "plumbers" }}
 {{ partial "js" . }}
{{ end }}

it is not working why?

I want the Hugo to place this partial where in section “plumbers” only on regular pages not on listing pages.

what I am doing wrong. I also try the below

{{ if and (eq .Section "plumbers") (not .IsPage "section") }}
 {{ partial "js" . }}
{{ end }}

and also tried this

{{ if and (eq .Section "plumbers") (ne .Type "section") }}
{{ partial "js" . }}
{{ end }}

Any solution will be appreciated. Thanks!

It looks a bit like you’re guessing, which is never a great strategy.

  1. .Site.HasRegularPages isn’t a thing
  2. .IsPage returns true for regular content pages, and doesn’t take arguments
  3. .Type returns the content type, not the page kind

I think you want:

{{ if and .IsPage (eq .Section "plumbers") }}
1 Like

Hi @jmooring

you are 100% right I was just guessing see what works and try to combine different things.

I was not able to make sense of documentation, the solution you provided works great.

Thanks

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