Params in a partial

Dear all,

I try to hugofy a theme from html5up.

I want to make the theme customizable via config.toml.

The theme has a frontpage with several entries that are set in config.toml. Everything works perfectly but in the sidebar nothing works. No values from config.toml are used. It seems that hugo simply does not work inside the sidebar.

So I am stuck.
Here is my code:

https://github.com/juh2/testsite/blob/master/config.toml

Eg. the contact infos are not shown:

https://github.com/juh2/testsite/blob/master/themes/hugo-editorial/layouts/partials/contact.html

The whole site is here.
https://github.com/juh2/testsite

If you start the site, you should see an open sidebar without any informations from config.toml. Informations on the main page are displayed.

I haven’t looked at the code, but you need to pass the page (or whatever) context as the last argument to the partial.

I don’t understand.

The same code is used in the main block defined in “index.html” and in a partial included by baseof.html.

In the baseofhtml-partial it does not work.

What @bep means is that you have to pass the page context, the ., to the partials that you’re using. Only with the context you’re able to access variables from the config file etc.

When you include the sidebar.html partial in the baseof.html template you have to add the . as last argument.

{{ partial "sidebar.html" . }}

Inside the sidebar.html partial you nested further partials that actually require the information that you can access trough the context.

Therefore, you have to pass the context to each (sub-)partial in sidebar.html as well, e.g.:

{{ partial "search.html" . }}
{{ partial "nav.html" . }}
...
1 Like

:astonished: These damn little dots.

Thanks
juh

@juh2 Which theme are you porting over?

@rdwatters The new editorial theme. https://html5up.net/editorial

@juh2 I just downloaded the editorial theme. Did the dot/context issue fix your question? If not, let me know and I can look at the code on the theme and will clone your repo. Thanks.

Yes, it’s fixed.

1 Like