| 1 |
--- |
| 2 |
title: Params |
| 3 |
description: Returns a map of resource parameters as defined in front matter. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: map |
| 9 |
signatures: [RESOURCE.Params] |
| 10 |
--- |
| 11 |
|
| 12 |
Use the `Params` method with [page resources](g). It is not applicable to either [global resources](g) or [remote resources](g). |
| 13 |
|
| 14 |
With this content structure: |
| 15 |
|
| 16 |
```tree |
| 17 |
content/ |
| 18 |
├── posts/ |
| 19 |
│ ├── cats/ |
| 20 |
│ │ ├── images/ |
| 21 |
│ │ │ └── a.jpg |
| 22 |
│ │ └── index.md |
| 23 |
│ └── _index.md |
| 24 |
└── _index.md |
| 25 |
``` |
| 26 |
|
| 27 |
And this front matter: |
| 28 |
|
| 29 |
{{< code-toggle file=content/posts/cats.md fm=true >}} |
| 30 |
title = 'Cats' |
| 31 |
[[resources]] |
| 32 |
src = 'images/a.jpg' |
| 33 |
title = 'Felix the cat' |
| 34 |
[resources.params] |
| 35 |
alt = 'Photograph of black cat' |
| 36 |
temperament = 'vicious' |
| 37 |
{{< /code-toggle >}} |
| 38 |
|
| 39 |
And this template: |
| 40 |
|
| 41 |
```go-html-template |
| 42 |
{{ with .Resources.Get "images/a.jpg" }} |
| 43 |
<figure> |
| 44 |
<img alt="{{ .Params.alt }}" src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}"> |
| 45 |
<figcaption>{{ .Title }} is {{ .Params.temperament }}</figcaption> |
| 46 |
</figure> |
| 47 |
{{ end }} |
| 48 |
``` |
| 49 |
|
| 50 |
Hugo renders: |
| 51 |
|
| 52 |
```html |
| 53 |
<figure> |
| 54 |
<img alt="Photograph of black cat" src="/posts/post-1/images/a.jpg" width="600" height="400"> |
| 55 |
<figcaption>Felix the cat is vicious</figcaption> |
| 56 |
</figure> |
| 57 |
``` |
| 58 |
|
| 59 |
See the [page resources][] section for more information. |
| 60 |
|
| 61 |
[page resources]: /content-management/page-resources/ |