.Site.Params not working at all, any suggestions?

I’m trying to rebuild my site and when I try to pass in custom variables added in hugo.toml, it wasn’t working. So I passed in just the following to see what I got:

{{ .Site.Params }}

Hugo returned the following on the page:

map[]

If I pass in just {{ .Params }} for the page params, I get the following:

map[date:2023-11-23 11:34:45 -0500 EST draft:false iscjklanguage:false lastmod:2023-11-23 11:34:45 -0500 EST menu:map[main:map[weight:1]] publishdate:2023-11-23 11:34:45 -0500 EST title:Home]

So for some odd reason Hugo is not letting me access site parameters. Very odd, its worked before in the same context.

Weird, that should work. Have you used the correct key for params in hugo.toml?

1 Like

This means that you haven’t configured any site params (or your configuration setup is not correct).

See Params | Hugo for an example.

Of course, if you could show us your hugo.toml file it would be easier to help you.

1 Like

Thanks, I think I figured it out from the doc link you put in.

I wasn’t nesting the custom params I wanted to use under the [params] section. So my params had to go from:

baseURL = 'https://example.org/'
languageCode = 'en-US'
title = "example"
author = 'example'
sitelogo = '/pics/header.webp'
copyrightyear = '2023'

To:

baseURL = 'https://example.org/'
languageCode = 'en-US'
title = "example"
[params]
    author = 'example'
    sitelogo = '/pics/header.webp'
    copyrightyear = '2023'

That seemed to work. Calling {{ .Site.Params }} in a layouts/partial file started returning “map[author=‘example’…]” and I’m able to call {{ .Site.Params.author }} for example and it returns what’s set in that param.

I think it’s a case of me trying to do things by memory, and I must have remembered wrongly about how to put in custom site parameters.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.