Params
Returns a map of resource parameters as defined in front matter.
Syntax
RESOURCE.Params
Returns
map
Use the Params
method with
page resources. It is not applicable to either
global resources or
remote resources.
With this content structure:
content/
├── posts/
│ ├── cats/
│ │ ├── images/
│ │ │ └── a.jpg
│ │ └── index.md
│ └── _index.md
└── _index.md
And this front matter:
---
resources:
- params:
alt: Photograph of black cat
temperament: vicious
src: images/a.jpg
title: Felix the cat
title: Cats
---
+++
title = 'Cats'
[[resources]]
src = 'images/a.jpg'
title = 'Felix the cat'
[resources.params]
alt = 'Photograph of black cat'
temperament = 'vicious'
+++
{
"resources": [
{
"params": {
"alt": "Photograph of black cat",
"temperament": "vicious"
},
"src": "images/a.jpg",
"title": "Felix the cat"
}
],
"title": "Cats"
}
And this template:
{{ with .Resources.Get "images/a.jpg" }}
<figure>
<img alt="{{ .Params.alt }}" src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
<figcaption>{{ .Title }} is {{ .Params.temperament }}</figcaption>
</figure>
{{ end }}
Hugo renders:
<figure>
<img alt="Photograph of black cat" src="/posts/post-1/images/a.jpg" width="600" height="400">
<figcaption>Felix the cat is vicious</figcaption>
</figure>
See the page resources section for more information.
Last updated:
January 19, 2025
:
Replace links to glossary terms with custom render hook syntax (69d7a781b)
Improve this page