From bf9bca9656d612b0d7cba0a869a69984c82f5647 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Tue, 21 Feb 2017 08:24:01 +0200 Subject: [PATCH] layouts: Add imageConfig to set height and width Hugo 0.18 introduced the imageConfig function which allows you to access the height and width of images, which makes bots consuming the structured data happy. --- layouts/_default/single.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index de9a14e..0b5f151 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -10,7 +10,11 @@ {{- with .Params.images -}}{{ range first 1 . }} "image": { "@type": "ImageObject", - "url": "{{ . | absURL }}" + "url": "{{ . | absURL }}", + {{ with (imageConfig (printf "/static/%s" .)) }} + "height": "{{ .Height }}", + "width": "{{ .Width }}" + {{ end }} }, {{- end -}}{{ end }} "url": "{{ printf "%s" .Permalink }}",