Hugo Dollar Sign Variable

Sep 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 }}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.