# Height
> 返回给定图像资源的高度。
- 官方英文原文：https://gohugo.io/methods/resource/height/
- 本页规范地址：https://hugozh.cn/methods/resource/height/
- 最近更新：2026-10-02
- 最后提交：912b1d3 chore(site): 添加 static/CNAME（hugozh.cn），供 GitHub Pages 等平台绑定自定义域名
- 签名：RESOURCE.Height
- 返回类型：int
- 站点：Hugo 中文文档（https://hugozh.cn/）· 社区维护的非官方中文翻译，如有出入以官方英文原文为准

---
> [!NOTE]
> 该方法可用于全局资源、页面资源或远程资源。

调用 `Height` 方法之前，请先用 [`reflect.IsImageResourceWithMeta`][] 函数确认 Hugo 能否确定图像尺寸。

```go-html-template
{{ with resources.GetMatch "images/featured.*" }}
  {{ if reflect.IsImageResourceWithMeta . }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ else }}
    <img src="{{ .RelPermalink }}" alt="">
  {{ end }}
{{ end }}
```

[`reflect.IsImageResourceWithMeta`]: /functions/reflect/isimageresourcewithmeta/

