{{ $isJPG := eq (path.Ext .Destination) ".jpg" }} {{ $isPNG := eq (path.Ext .Destination) ".png" }} {{ if ($isJPG) -}} {{ $webpPath:= replace .Destination ".jpg" ".webp" }} {{ $webpPathStatic:= printf "static/%s" $webpPath }} {{ if (fileExists $webpPathStatic) -}} {{- end }} {{- end }} {{ if ($isPNG) -}} {{ $webpPath:= replace .Destination ".png" ".webp" }} {{ $webpPathStatic:= printf "static/%s" $webpPath }} {{ if (fileExists $webpPathStatic) -}} {{- end }} {{- end }} {{- $img := .Page.Resources.GetMatch .Destination -}} {{- if and (not $img) .Page.File -}} {{ $path := path.Join .Page.File.Dir .Destination }} {{- $img = resources.Get $path -}} {{- end -}} {{ .Text }}