I'm new to using Hugo and Go Templates. How can I access a variable from a partial file that is defined in base file using Hugo?
For eg: I have an index.html
file which contains code that reads the data stored in the events.json
file in the data directory and stores it in a variable. How can I access that variable from another file?
index.html
{{ $events := .Site.Data.events }}
{{ partial "people" . }}
people.html
// access the events variable from the index.html
{{ $events }}
I really hope this makes sense. I can try and clarify more if needed.
dict
π . By the way, please fix the rounded bracket after$events
, it should be curly brace. I can't suggest edit since it's less than 6 chars long. β Quod