Build failure when instagram/vimeo posts no longer exist

I’ve read a couple of other threads about this error, but I seem to have a different problem. I have a custom shortcode in my /layouts/shortcodes folder for Instagram and Vimeo so that they run when offline, but when online use the internal one:

 {{ if not .Site.IsServer }}
    {{ template "_internal/shortcodes/instagram.html" . }}
    {{ else }}
    <!-- Render the placeholder for the shortcode -->
    <pre>Instagram Photo: {{ .Get 0 }}</pre>
    {{ end }}

But now I get the build errors on Netlify when I deploy:

ERROR 2020/07/25 06:30:22 Failed to get JSON resource "https://vimeo.com/api/oembed.json?url=https://vimeo.com/1496857": Failed to retrieve remote file: Not Found

8:30:23 AM: ERROR 2020/07/25 06:30:23 Failed to get JSON resource "https://api.instagram.com/oembed/?url=https://www.instagram.com/p/BqxGoy1gGPI/&amp;maxwidth=640&amp;omitscript=true": Failed to retrieve remote file: Not Found

I checked those two Instagram and Vimeo posts and they no longer exists. That’s okay, I can remove them from my blog post, but that’s not very robust. I’d prefer the posts just to show a dud embed than the build to fail.

Any ideas?

1 Like

Ah, okay, thanks.