# Error with layouts/type/\_markup/render-{kind}.html

**URL:** <https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886>\
**Category:** support\
**Created:** [April 13, 2023, 1:07pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886 "2023-04-13T13:07:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [April 13, 2023, 1:07pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/1 "2023-04-13T13:07:17Z")

</div>

Hi.  
I made a different render-image for the homepage (with type:home) and it’s seen as such, but I have this error message:

> “/home/drm/WEBSITE/themes/hugo-book/layouts/home/\_markup/render-image.html:24:13”: execute of template failed: template: home/\_markup/render-image.html:24:13: executing “home/\_markup/render-image.html” at \<$img.Width\>: error calling Width: this method is only available for image resources

```auto
  {{ $quality = .Page.Param "imaging.quality" }}
{{ end }}
{{ if gt $img.Width 1540 }}
	{{ $large = $img.Resize (print "1540x q" $quality) }}
{{ else }}

```

What’s wrong here ?

> **Complete file**
>
> {{- $img := “” -}}  
> {{- $smallest := “” -}}  
> {{- $small := “” -}}  
> {{- $medium := “” -}}  
> {{- $large := “” -}}
> 
> {{- /\* Get image resource. \*/}}  
> {{- $destination := urls.Parse .Destination }}  
> {{- $img := “” }}  
> {{- if $destination.IsAbs }}  
> {{- $img = resources.GetRemote $destination.String }}  
> {{- else }}  
> {{- with .Page.Resources.Get (urls.Parse .Destination).Path }}  
> {{- $img = . }}  
> {{- else }}  
> {{- $img = resources.Get $destination.Path }}  
> {{- end }}  
> {{- end }}
> 
> {{ $quality := 100 }}  
> {{ if gt (len $img.Content) 100000 }}  
> {{ $quality = .Page.Param “imaging.quality” }}  
> {{ end }}  
> {{ if gt $img.Width 1540 }}  
> {{ $large = $img.Resize (print “1540x q” $quality) }}  
> {{ else }}  
> {{ $large = $img.Resize (printf “%dx%d q%d” $img.Width $img.Height $quality) }}  
> {{ end}}  
> {{ if gt $img.Width 1000 }}  
> {{ $medium = $img.Resize (printf “1000x q%d” $quality) }}  
> {{ else }}  
> {{ $medium = $img.Resize (printf “%dx%d q%d” $img.Width $img.Height $quality) }}  
> {{ end}}  
> {{ if gt $img.Width 604 }}  
> {{ $small = $img.Resize (printf “604x q%d” $quality) }}  
> {{ else }}  
> {{ $small = $img.Resize (printf “%dx%d q%d” $img.Width $img.Height $quality) }}  
> {{ end}}  
> {{ if gt $img.Width 200 }}  
> {{ $smallest = $img.Resize (printf “200x q%d” $quality) }}  
> {{ else }}  
> {{ $smallest = $img.Resize (printf “%dx%d q%d” $img.Width $img.Height $quality) }}  
> {{ end }}
> 
> {{ with .Title }}{{.|$.Page.RenderString}}{{ end }} ![]( "{{ . }}")

I don’t think I changed anything important, especially in the beginning. Just removed the useless parts.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [April 13, 2023, 1:12pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/2 "2023-04-13T13:12:36Z")

</div>

> [@Tom\_Durand](#):
>
> /home/drm/WEBSITE/themes/hugo-book/layouts/home/\_markup/render-image.html:24:13:

Are you sure there’s no … error message?

If I would guess, you have some pages without imaging.quality set. try:

```auto
 {{ $quality = .Page.Param "imaging.quality" | default 50 }}

```

---

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [April 13, 2023, 1:14pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/3 "2023-04-13T13:14:40Z")

</div>

My bad, I badly copied the error message.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [April 13, 2023, 1:18pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/4 "2023-04-13T13:18:29Z")

</div>

OK, you have somehow found a resource that’s something other than a raster image (e.g. a text file).

You can check the media type with e.g. `$img.MediaType.MainType` which should be `image`.

---

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [April 13, 2023, 1:23pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/5 "2023-04-13T13:23:42Z")

</div>

no it has to be a syntax mistake, because everything worked before. Even without `default`.  
Is this the good syntax for what it’s obviously supposed to mean ?

```auto
  {{ $quality = (default .Site.imaging.quality .Page.Params.imaging.quality) }}

```

with this in my config:

```auto
[imaging]
  anchor = 'Smart'
  bgColor = '#ffffff'
  hint = 'picture'
  quality = 75

```

Error:

> Error: Error building site: “/home/drm/WEBSITE/content/docs/Biology/virus-exosome-en.md:1:1”: “/home/drm/WEBSITE/themes/hugo-book/layouts/\_default/\_markup/render-image.html:25:32”: execute of template failed: template: \_default/\_markup/render-image.html:25:32: executing “\_default/\_markup/render-image.html” at \<.Site.imaging.quality\>: can’t evaluate field Site in type goldmark.imageLinkContext

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [April 13, 2023, 4:50pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/6 "2023-04-13T16:50:25Z")

</div>

Use `site.Image.quality`. I think the context is not the page context, but e.g. `with` or `range`. Using `site` avoids using the (`.`) which changes.

---

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [April 13, 2023, 5:48pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/7 "2023-04-13T17:48:37Z")

</div>

You must mean site.imag **ing**.quality I suppose. still complaining.

> execute of template failed: template: \_default/\_markup/render-image.html:25:26: executing “\_default/\_markup/render-image.html” at : can’t evaluate field Image in type interface {}  
> Built in 537 ms

line 25 is:

> {{ $quality = default site.imaging.quality .Page.Params.imaging.quality }}

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [April 13, 2023, 6:09pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/8 "2023-04-13T18:09:37Z")

</div>

Do you have any SVGs? They can’t have quality changed but detect as images.

---

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [April 13, 2023, 6:11pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/9 "2023-04-13T18:11:14Z")

</div>

None going through the render-hook.  
Here’s a sample:  
[https://drive.google.com/drive/folders/1wG\_qK0jXQfpaIVodJKUWVTKfTK3xg6US?usp=share\_link](https://drive.google.com/drive/folders/1wG_qK0jXQfpaIVodJKUWVTKfTK3xg6US?usp=share_link)

---

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [April 13, 2023, 9:16pm UTC](https://discourse.gohugo.io/t/error-with-layouts-type-markup-render-kind-html/43886/10 "2023-04-13T21:16:41Z")

</div>

found the solution.  
i replaced `type: home` but `layout: home`. Pfff, if that is not confusing I don’t know what it is. And it ain’t gonna change…  
I would still suggest though, explaining on the site the difference in behavior. this sðit is confusing as hell. Using type did apply to the homepage, but to apparently all the other pages too since the error message concerned a completely unrelated page.
