Hugo Dollar Sign Variable

September 9, 2017
.Title vs $.Title

Dollar sign ($) variable is used to refer to variable in the global scope.

Assuming you are editing template in layouts/_default/single.html

  • .Title and $.Title will refer to current page title.
  • When you are in a loop of range .Site.Pages, .Title will refer each .Site.Pages title, while $.Title still refer to current page title.
CurrentPageTitle={{ .Title }}
CurrentPageTitle={{ $.Title }}

{{ range .Site.Pages }}
  Title={{ .Title }} - CurrentPageTitle={{ $.Title }}
{{ end }}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.