.Site vs site and failed Netlify builds

Sometimes I see code examples and themes that use site.Params.heading instead of .Site.Params.Heading when accessing Site parameters.

“site” seems benign, and will build locally when running hugo. But when I deploy to Netlify “site” always breaks.

What is the purpose of site vs .Site - it seems to me .Site is always the correct choice?

site is a global function. It allows to access the site variables without a page context.

Pretty handy when needing site methods from within a partial to which no page context is available.

I think site was introduced in Hugo 52 or 53 so better make sure the version your Netlify instance is using has it.


I see, yeah I’m using 51 on Netlify. Thanks!

And I’m using 54 locally, bad idea!

1 Like