Width
Returns the width of the given image resource.
- Syntax
- RESOURCE.Width
- Returns
- int
Use this method with global resources, page resources, or remote resources.
Use the reflect.IsImageResourceWithMeta function to verify that Hugo can determine the dimensions before calling the Width method.
{{ with resources.GetMatch "images/featured.*" }}
{{ if reflect.IsImageResourceWithMeta . }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ else }}
<img src="{{ .RelPermalink }}" alt="">
{{ end }}
{{ end }}Last updated:
September 11, 2026
:
content: Comply with function/method description guidance in style guide (76fa3fc9e)
Improve this page