I'm creating a page. I have a site-wide parameter defined in my default config.toml file like this.
[Params]
tdName= "Mr. Tournament Director"
In my page I'm writing:
{{ .Site.Params.tdName }}
Rather than the string in quotes, the code below that is litterally showing up when I run the "hugo server" command. What am I doing wrong?
Thanks.
To specify Go template code in a file in the content
directory, you need to use a Hugo shortcode. For example, you could use this inline shortcode:
{{< tdname.inline >}}
{{ site.Params.tdName }}
{{< /tdname.inline >}}
To use inline shortcodes, as I do above, you need to set enableInlineShortcodes
to true in your config file.
Note that:
site.Params.tdName
is usually equivalent to .Site.Params.tdName
but is better because it is context free (no leading dot (.))tdName
to td_name
or tdname
or something without upper case characters.