Is it better to always write site.Params over .Site.Params or $.Site.Params?

I see .Site.Params and $.Site.Params in almost all examples but .Site.Params can break depending on what the dot is set to whereas site.Params (the global version) should work everywhere and is shortest. Are there any cases where the first two would make more sense before I do a hasty global search and replace in a project? :slight_smile: Thanks!

There is no better or worse. It’s only a matter of preference.

site is a function that operates from the global context, so that the template context doesn’t matter.

Since site has been introduced I’ve never used .Site anymore. With the first one you’ll never have to worry about the current context… so why bother :man_shrugging:

site function. It sounds great.
But I cannot find information about the use of this function in the Documentation.

I do not maintain the Hugo Docs.

Feel free to open an issue over here: Issues · gohugoio/hugoDocs · GitHub

Not sure why this was closed: Document existence of site global function · Issue #1119 · gohugoio/hugoDocs · GitHub

See: Site variables | Hugo

All the methods below, e.g. .Site.RegularPages can also be reached via the global site function, e.g. site.RegularPages , which can be handy in partials where the Page object isn’t easily available.

Thank you so much @pointyfar