# Shortcode works locally but not on Netlify

**URL:** <https://answers.netlify.com/t/shortcode-works-locally-but-not-on-netlify/119787>\
**Category:** Support\
**Tags:** deployment, building, hugo\
**Created:** [June 4, 2024, 6:27pm UTC](https://answers.netlify.com/t/shortcode-works-locally-but-not-on-netlify/119787 "2024-06-04T18:27:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam.rogers](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/sam.rogers/32/51346_2.png) [@sam.rogers](https://answers.netlify.com/u/sam.rogers)\
**Post date:** [June 4, 2024, 6:27pm UTC](https://answers.netlify.com/t/shortcode-works-locally-but-not-on-netlify/119787/1 "2024-06-04T18:27:20Z")

</div>

Hi all,

I’m wondering if anyone can shed some light as to why my build is failing on Netlify but not locally?  
I have an example repo (which incidentally works on Netlify 🥹) [here](https://github.com/rogerssam/hugo-testing).

What I’m trying to do is create a shortcode that does some simple image processing (resizing) for markdown images. Shortcode is [as follows](https://github.com/rogerssam/hugo-testing/blob/main/layouts/shortcodes/image.html):

```auto
<!-- Get src param from shortcode -->
{{ $src := $.Get "src"}}

<!-- Get alt param from shortcode -->
{{ $alt := $.Get "alt"}}

<!-- Get image -->
{{$img := resources.Get $src}}

<!-- Resize image as a test it's working -->
{{- $orig := $img.Resize "1200x"}}
{{- $small := $img.Resize "500x webp"}}
{{- $medium := $img.Resize "780x"}}
{{- $large := $img.Resize "1000x webp" }}
{{- $xlarge := $img.Resize "1200x webp" }}

<picture>  
    <source 
      type="image/webp"
      srcset="
      {{ $small.RelPermalink }} 500w,
      {{ $medium.RelPermalink }} 780w,
      {{ $large.RelPermalink }} 1000w,
      {{ $xlarge.RelPermalink }} 1200w" 
      sizes="50vw">
    <img 
      srcset="{{ $small.RelPermalink }} 500w,
      {{ $medium.RelPermalink }} 780w,
      {{ $large.RelPermalink }} 1000w,
      {{ $xlarge.RelPermalink }} 1200w" 
      src="{{ $orig.RelPermalink }}" 
      alt="{{ $alt }}">
  </picture>

```

And [example use](https://github.com/rogerssam/hugo-testing/blob/ba3a18fb3e3da3463d84e42c8683a528024ae7d7/content/faq.md?plain=1#L8) with the image in the `assets/img` folder:

```auto
{{< image src="img/blog.jpg" >}}

```

Now this works fine locally, and resizes images wonderfully, but when I deploy to Netlify I get the following error:  
`shortcodes/image.html:11:17: executing "shortcodes/image.html" at <$img.Resize>: nil pointer evaluating resource.Resource.Resize`

I initially thought this was an error due to Hugo version difference between local and Netlify, however I’ve tried different versions of Hugo on Netlify (including what I run locally) but with no luck.  
Any other suggestions of reasons why this build is failing? I have cross posted on the Netlify forums.

---

<div class="post-metadata">

**Author:** ![Andrew.H](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/andrew.h/32/59713_2.png) [@Andrew.H](https://answers.netlify.com/u/Andrew.H)\
**Post date:** [June 4, 2024, 8:23pm UTC](https://answers.netlify.com/t/shortcode-works-locally-but-not-on-netlify/119787/2 "2024-06-04T20:23:20Z")

</div>

Hey @sam.rogers

Welcome to the forums!

The error message `nil pointer evaluating resource.Resource.Resize` indicates that the `$img` variable is `nil` at the point where the `Resize` function is called. This would happen when the image resource cannot be found or loaded

Because it’s working locally, and not on Netlify, I’m thinking the reason may be an Image Path Issue, or possibly Case Sensitivity. Locally, the image might be found due to differences in the filesystem or working directory, but in the Netlify build environment, the path is different, and on Netlify it the file structure **is** case sensitive.

---

<div class="post-metadata">

**Author:** ![sam.rogers](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/sam.rogers/32/51346_2.png) [@sam.rogers](https://answers.netlify.com/u/sam.rogers)\
**Post date:** [June 4, 2024, 11:14pm UTC](https://answers.netlify.com/t/shortcode-works-locally-but-not-on-netlify/119787/3 "2024-06-04T23:14:37Z")

</div>

Thanks @Andrew.H, you were right on the money with the case sensitivity. Turns out git doesn’t care about case on Windows (in this particular situation anyway), but obviously Netlify, like all good Linux systems, does!

Many thanks for your help. I’ll add that to my list to remember to check for next time 😉
