Difference between .Params and .Param

Can anybody please explain the difference between .Params and .Param? I don’t understand the docs in this case. Tnx.

So, in a template:

  • .Params will give you the Page params map (defined in the current Page’s front matter)
  • .Site.Params will give you the Site params map (defined in site config)
  • .Param is a method that takes a key as an argument; it will first look in the page’s params, and if not found, it defaults to the site param’s value.

.Param is a method to call a page or site variables into your template e.g. $.Param “image” will look for a parameter called image in a your frontmatter or in your config

See here: https://gohugo.io/functions/param/#readout

.Params is used either in the context of .Site.Params and it is a container with the values from the params section of your config https://gohugo.io/variables/site/#the-site-params-variable

Or as way to call frontmatter parameters in your template
e.g. {{ with .Params.venue }}{{ . }}{{ end }}

Super explanations - thank you all. That was one of my last questions. Hugo is getting better and better for me.

1 Like

A post was split to a new topic: How can one use range where and use $.Param?

Gonna close this, but wanted to say…

One of them ends with “s”. :stuck_out_tongue_winking_eye:

1 Like