# Twitter Short Code Timeout

**URL:** <https://discourse.gohugo.io/t/twitter-short-code-timeout/17326>\
**Category:** support\
**Created:** [March 1, 2019, 7:19pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326 "2019-03-01T19:19:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MatthewMcD](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/matthewmcd/32/5578_2.png) [@MatthewMcD](https://discourse.gohugo.io/u/MatthewMcD)\
**Post date:** [March 1, 2019, 7:19pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326/1 "2019-03-01T19:19:46Z")

</div>

I am using the Twitter Short Code and nearly every other build is failing with:

```auto
Building sites … WARN 2019/02/25 16:40:21 Timed out creating content for page "D:\\home\\site\\repository\\content\\blog\\2019-02-15-itpro-level-up.md" (.Content will be empty). This is most likely a circular shortcode content loop that should be fixed. If this is just a shortcode calling a slow remote service, try to set "timeout=30000" (or higher, value is in milliseconds) in config.toml.

```

Before I change the timeout I was wondering why this would crash the build of the entire page. I could understand if the short code failed to render, but it seems odd that the whole page would be lost.

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [March 1, 2019, 7:35pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326/2 "2019-03-01T19:35:58Z")

</div>

Perhaps the Twitter API is slow to respond when `getJSON` is called

> <https://github.com/gohugoio/hugo/blob/c52045bbb38cbf64b9cb39352230060aa122cc9f/tpl/tplimpl/embedded/templates/shortcodes/twitter.html>

---

<div class="post-metadata">

**Author:** ![MatthewMcD](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/matthewmcd/32/5578_2.png) [@MatthewMcD](https://discourse.gohugo.io/u/MatthewMcD)\
**Post date:** [March 1, 2019, 8:05pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326/3 "2019-03-01T20:05:00Z")

</div>

I am certain that is the basis of the problem, I just wonder why it crashes the whole page build. I increased my timeout to 30s.

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [March 1, 2019, 8:06pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326/4 "2019-03-01T20:06:45Z")

</div>

> [@MatthewMcD](#):
>
> I just wonder why it crashes the whole page build

That’s a question for a Hugo developer. I’m sure there are reasons for this, I just have no idea what they are.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [March 1, 2019, 8:35pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326/5 "2019-03-01T20:35:34Z")

</div>

This has come up before. If you want to read up on the details then please use the search button in the Forum and also search Hugo’s issue tracker on GitHub.

There was some discussion on GitHub aimed towards addressing this issue but in the end it was decided that when `getJSON` fails then a project’s build should also fail because this is -after all- an ERROR that needs to be fixed and not masked.

Also note that the above is a recap of the discussion (as I remember it). It is not my opinion.

My advice would be to stop fetching external assets this way.

For posterity it is always preferable to store a tweet’s JSON under `/data/` and then simply call it via a shortcode as needed.

---

<div class="post-metadata">

**Author:** ![MatthewMcD](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/matthewmcd/32/5578_2.png) [@MatthewMcD](https://discourse.gohugo.io/u/MatthewMcD)\
**Post date:** [March 1, 2019, 8:46pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326/6 "2019-03-01T20:46:02Z")

</div>

Interesting, would this advice apply to other built in short codes like Instagram too?

Is there guidance on how to “store the tweet’s JSON”?

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [March 1, 2019, 8:51pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326/7 "2019-03-01T20:51:28Z")

</div>

> [@MatthewMcD](#):
>
> Is there guidance on how to “store the tweet’s JSON”?

It is not complicated at all. Hugo’s internal shortcodes use the public oEmbed API.

You can have a look at each internal shortcode over [here](https://github.com/gohugoio/hugo/tree/master/tpl/tplimpl/embedded/templates/shortcodes)

For a tweet the oEmbed URL is in the form of: `https://api.twitter.com/1/statuses/oembed.json?id=<enter-tweet-id>`

It’s the same for Instagram: `https://api.instagram.com/oembed/?url=https://instagram.com/p/<insert-post-ID>`

Also note that you may want to have a look at the Simple Shortcodes that can be enabled via the [privacy config](https://gohugo.io/about/hugo-and-gdpr/) if you plan to do this for Instagram.

---

<div class="post-metadata">

**Author:** ![MatthewMcD](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/matthewmcd/32/5578_2.png) [@MatthewMcD](https://discourse.gohugo.io/u/MatthewMcD)\
**Post date:** [March 2, 2019, 1:33pm UTC](https://discourse.gohugo.io/t/twitter-short-code-timeout/17326/8 "2019-03-02T13:33:38Z")

</div>

Thanks, I think I’ll change the post and avoid the overhead of the Twitter short code all together.
