Hugo 錯誤訊息: You may have a circular loop in a shortcode

Post Title Image (圖說:Timeout。圖片來源:Photo by Luca Severin on Unsplash。)

某天升級了 Hugo 之後突然被這個錯誤訊息卡住(如下備忘),而且一直卡在固定的某一篇文章上,左思右想,最近也沒有新的改動,難道是升級 Hugo 後 shortcode 有破壞性的變更?


內容大綱


 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

後來使用 hugo --debugtig status 觀察到 resources/_gen/images/xxx_1.gif 的檔案跑出來,思路就從 debug shortcode 轉變成那來延長 timeout 時間長度限制,看起來預設值在 30000 ms,先改成 60000 ms 再跑一次 hugo --debug,感覺卡住的位置有更換,但還是發生 timeout,直覺改成再多加一個 0 變成 600000 ms 就解掉過關了。有點鬧…

解法是:加入新的 timeout 數值在 config.toml 裡頭。這個數字在你的環境也許需要依數量級再做更改。

timeout = 600000

然後就放著讓他跑,花費了 144700 ms。

❯ 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

整個 build 過一次之後,再跑我自己的 blogserv 就跟以往一樣順暢了:

❯ 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

Buy Me a Coffee 如果這個分享對你有幫助,你也覺得有點鬧,歡迎拍打餵食一杯咖啡 ☕ XDD

參考資料

Loading comments…