.Site.IsServer doesn't work

I want my site to render differently locally but I’m having trouble getting conditions to work.

If I use this:

{{ if .Site.IsServer }}
do something
{{ end }}

I get this error:

ERROR 2018/07/27 17:19:34 Error while rendering “home”: template: /index.html:9:12: executing “/index.html” at <.Site.IsServer>: can’t evaluate field IsServer in type *hugolib.SiteInfo

I have also tried

{{ if eq .Site.BaseURL “http://localhost:3000” }} <<< always resolves false even if {{ .Site.BaseURL }} prints “http://localhost:3000

My Hugo version: Hugo Static Site Generator v0.44/extended darwin/amd64 BuildDate: unknown

IsServer was added not long ago, but it is in 0.44 – so that suggests that the version you think you are running isnt’t the version you are running. A path issue?

Good catch, thank you! I’m using hugo-bin with Gulp, not actual Hugo, and it was out of date.

1 Like