(Illustration: Timeout. Image source: Photo by Luca Severin on Unsplash)
After upgrading Hugo one day, I was suddenly stuck by this error message (paste below), and I have been stuck on a specific Hugo post content. I have been thinking about it, and I have no new changes recently. Is it because there is some kind of destructive modification on the Hugo shortcode? I didn’t find any hint in the release notice of Hugo.
Contents
❯ blogserv
Start building sites …
hugo v0.104.3+extended darwin/arm64 BuildDate=unknown
Error: Error building site: "/Users/dwchiang/projects/ernestchiang/www/content/posts/2021/2021-04-13-implementing-cloudfront-lambda-at-edge-oauth2.en.md:1:1": timed out initializing value. You may have a circular loop in a shortcode, or your site may have resources that take longer to build than the `timeout` limit in your Hugo config file.
Built in 30717 ms
Later, I used hugo --debug
and tig status
to observe that the files resources/_gen/images/xxx_1.gif
came out, my idea was changed from debug shortcode to that to extend the timeout time limit, it seems that the default timeout value is 30000 ms, my first change makes it to 60000 ms, and then run hugo --debug
again. I feel that the stuck position has been moved, but a timeout still occurs. I intuitively change it to add one more 0 to become 600000 ms, and it works. kinda funny…
The solution is: add a new timeout value in config.toml
. This number may need to be changed by your environment.
timeout = 600000
Then just let hugo run, it took 144700 ms in my case.
❯ hugo --debug
Start building sites …
hugo v0.104.3+extended darwin/arm64 BuildDate=unknown
INFO 2022/10/16 22:01:35 syncing static files to /
DEBUG 2022/10/16 22:01:35 creating alias: /en/posts/2020/2020-08-01-playing-with-firecracker redirecting to https://www.ernestchiang.com/en/posts/2020/playing-with-firecracker/
... (skipped) ...
DEBUG 2022/10/16 22:03:59 Render XML for "sitemapindex" to "sitemap.xml"
| EN | ZH
-------------------+-----+------
Pages | 215 | 278
Paginator pages | 11 | 15
Non-page files | 45 | 44
Static files | 659 | 659
Processed images | 696 | 484
Aliases | 107 | 137
Sitemaps | 2 | 1
Cleaned | 0 | 0
Total in 144700 ms
After the whole build successfully once, running my own blogserv is as smooth as before:
❯ blogserv
Start building sites …
hugo v0.104.3+extended darwin/arm64 BuildDate=unknown
| EN | ZH
-------------------+-----+------
Pages | 227 | 286
Paginator pages | 14 | 17
Non-page files | 45 | 44
Static files | 659 | 659
Processed images | 704 | 483
Aliases | 119 | 141
Sitemaps | 2 | 1
Cleaned | 0 | 0
Built in 1757 ms
If you enjoy the solution, please feel free to buy me a cup of coffee ☕ :)