$.Site.Title not working inside data range

Any Global site variable not working anymore inside partials

I have this range on homepage

{{ range .Site.Data.home.categories }}
  {{ partial "home_category.html" . }}
{{ end }}

in home_category.html partial

<li>
<h3>{{ .name }}</h3>
{{ print $.Site.Title }}
</li>

$.Site.Title shows nil ?

The context inside the partial is defined by the argument you pass to it. The “category” you are passing to the partial has no reference back to .Site.

Since you can only pass a single argument to a partial, you need to send a map/dictionary. Something like this should work:

{{ partial "home_category.html" (dict "site" $.Site "category" .) }}
<li>
<h3>{{ .category.name }}</h3>
{{ print .site.Title }}
</li>
3 Likes