Variables in {{ .Content }}

Hi,
I have my md file like:
+++
title = “Team”
id = “single_page”
header = “header_team”
html = “fausto”
+++
Our team
< div class=“mini-hero”>
render the variable html here…
</ div>

How can I reference the variable HTML so that is rendered inside the div “mini-hero”?

F.

1 Like

That’s great thanks!
Is there a way ( I haven’t found one online ) to pass a page variable to the shortcode as a parameter ( like html one in my example )

F.

Found my own solution:

I used this in the shortcode:

{{$.Page.Params.prova}}

Can I pass html with markup in the variable?

Since a recent Hugo version (cannot remember which) you can use raw string litterals with newlines as parameter, e.g.:

{{< myshortcode `this is some <b>HTML</b>
and then some.` >}}

Note the special quotes.

Also note that I suspect that you instead of the above in most cases want to use inner content and also remember that shortcodes can be nested.

1 Like