Hugo fails to build if Tweet is deleted

I was debugging another issue, and at some point I got an error on build:

~/Labs/Digital-Insanity  $ hugo server
Building sites … ERROR 2018/08/06 00:02:18 Failed to get json resource with error message Failed to retrieve remote file: Forbidden
ERROR 2018/08/06 00:02:18 error processing shortcode "_internal/shortcodes/tweet.html" for page "post/2017-12-13-danharmon/": template: _internal/shortcodes/tweet.html:7:13: executing "_internal/shortcodes/tweet.html" at <getJSON $url>: error calling getJSON: Failed to retrieve remote file: Forbidden
Total in 11062 ms
Error: Error building site: logged 1 error(s)

I went to look at the post causing the error and … wubba lubba dub dub. Found out that Dan Harmon got bullied for past mistakes and deleted his twitter account. I worked around it, so this isn’t a pain right now. Still maybe we can make the current tweet shortcode a bit more forgiving.

1 Like

I’ve always respected Twitter for giving individuals peace of mind in allowing them to remove their property from the service. Not all services allow content creators to remove content which can cause psychological harm in cases of cyberbullying. Sorry to hear that happened. Maybe an option to disable the prerender would suffice, if not already available, under abend.

Maybe the tweet content could be cached in the resource directory

I’m not a fan of caching by default. In this case the information was innocuous, but it could have been sensitive and the author wished to delete the account and all associated content. The owner of the site can and should use his/her judgement to decide if the tweet should be recovered from a previous build or not.

What do you have in mind?

I can see where you are coming from but IMO once you’ve tweeted something publicly and someone has now quoted you on their site then it’s a matter of public record at that point.

@maiki maybe something in the lines of showing a message that the content was removed.

“Content of link to tweet is unavailable or may have been removed by the author”.


I just encountered this for the first time in a while and it finally occurred to me to just render the tweet entirely in the browser by overriding Hugo’s built-in tweet shortcode:

<div id="tweet-container-{{ .Get 0 }}"></div>
    '{{ .Get 0 }}',
    document.getElementById('tweet-container-{{ .Get 0 }}'),

To keep it dead simple, I’m loading synchronously in the page <head>

Definitely not the most elegant but invalid tweet IDs just fail silently in the browser and can’t break the Hugo build.