.Site.Params access in a theme partial

Hi All,

I’ve having some trouble, and either my google fu is weak (likely) or something else is up.

I’m trying to access .Site.Params. defined in config.toml from a partial in a custom theme I’m working on - but it I can’t access any vars.

If I move the code to a layout file (instead of a partial) it works.

The partial is definitely being loaded (I can see the plain html from the partial make it into the final build of the site).

Any ideas what I’m doing wrong?

Har to say without seeing what you’re doing, but you have to make sure to pass on the “correct context” to the partial to be able to access the Site.

Fair call - sorry, I should have included some code.

<div class="blurb"> {{ .Site.Params.description }} </div>

<div class="four columns"> {{ partial "column.html" }} </div>

theme = "bluejam" [params] description = "Some text"

Hopefully that helps?

You have to pass the context down to the partial.

This is probably what you want:

{{ partial "column.html" . }}      

I say probably because it is hard to say without seeing the full picture. Getting the context right is maybe the hardest thing in Go templates. A trick can sometimes be to always use $. when refering to the outer-most context (page, node, shortcode).

1 Like

Passing down the context down using the extra “.” I missed absolutly fixed the problem. Thankyou bep!