参数
Syntax
RESOURCE.Params
Returns
map
使用 Params 方法与 页面资源 一起使用。它不适用于 全局 或 远程 资源。
使用此内容结构:
content/
├── posts/
│   ├── cats/
│   │   ├── images/
│   │   │   └── a.jpg
│   │   └── index.md
│   └── _index.md
└── _index.md
以及此前置内容:
content/posts/cats.md
 
 
 
---
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"
}
以及此模板:
{{ 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 渲染结果:
<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>
更多信息,请参见 页面资源 部分。