configurationhugouser-defined

Making User Variable From config.toml Show Up In Page Body


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.


Solution

  • 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: