.Site vs $.Site vs site

If the current context[1] is a Page, you can use .Site.

If the current context is not a Page and the template context[2] is a Page, you can use $.Site. The $ gets you to the template context.

If neither the current context nor the template context include a Page, use the global site function. For example, inside of a partial that receives a slice of integers.

https://gohugo.io/templates/introduction/


  1. The value of the dot at any point in the template. It is equivalent to the template context unless it is rebinded via a with or range statement. ↩︎

  2. The value of the dot at the top of the template, representing the context passed into the template. ↩︎