How to pass multiple parameters to local objects in Hugo? It is not as simple as it seems, you need to use skills. Let us find out.
I use Hugo to manage this website. It's so cool.
One thing that got me stuck today is passing 2 parameters to some parameters.
Due to partial inaccessibility.Site.Pages
To get a list of pages of a website (due to scope issues), I have to create a dictionary and fill it with 2 items:
{{ partial "my-partial.html" (dict "context" . "pages" $.Site.Pages) }}
The key here is to pass(dict "context" . "pages" $.Site.Pages)
As a parameter instead of.
Use local subs as usual.
Now in the local, instead of using.
Access the current context variables you want to use.context
.
And access the value assigned topages
, I will use.pages
.
Of course you can also pass multiple items. Just add more items todict
.