gora
1
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.
.Site.HasRegularPages
isn’t a thing
.IsPage
returns true for regular content pages, and doesn’t take arguments
.Type
returns the content type, not the page kind
I think you want:
{{ if and .IsPage (eq .Section "plumbers") }}
1 Like
gora
3
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
system
Closed
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.