2022年1月

Hugoでデプロイする時たまにビルドエラーになる原因

Hugoでデプロイする時たまにビルドエラーになる原因

 Hugo
 2022-01-29

GitHub Actionsを使ったHugoのデプロイ時に、たまにエラーになっていたんですが原因が分かりました。

package.json

  "scripts": {
    "create-ranking": "node scripts/create-ranking.js",
    "build": "hugo --gc --minify",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

npm run buildしてみるとこんな感じのエラーが出て、たまにデプロイがうまくいきませんでした

Start building sites … 
hugo v0.89.4-AB01BA6E darwin/amd64 BuildDate=2021-11-17T08:24:09Z VendorInfo=gohugoio
ERROR 2022/01/29 20:21:30 render of "page" failed: execute of template failed: template: partials/sidebar.html:101:72: executing "sidebar" at <(index $thumbnail 0).Fill>: error calling Fill: image "/Users/okdyy75/hugo-theme-salt/content/article/hugo/fontawsome/thumbnail.png": this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information
ERROR 2022/01/29 20:21:30 render of "page" failed: execute of template failed: template: partials/sidebar.html:101:72: executing "sidebar" at <(index $thumbnail 0).Fill>: error calling Fill: image "/Users/okdyy75/hugo-theme-salt/content/article/hugo/fontawsome/thumbnail.png": this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information
ERROR 2022/01/29 20:21:30 render of "page" failed: execute of template failed: template: partials/sidebar.html:101:72: executing "sidebar" at <(index $thumbnail 0).Fill>: error calling Fill: image "/Users/okdyy75/hugo-theme-salt/content/article/hugo/fontawsome/thumbnail.png": this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information
ERROR 2022/01/29 20:21:30 render of "page" failed: execute of template failed: template: partials/sidebar.html:101:72: executing "sidebar" at <(index $thumbnail 0).Fill>: error calling Fill: image "/Users/okdyy75/hugo-theme-salt/content/article/hugo/fontawsome/thumbnail.png": this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information
Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: partials/sidebar.html:101:72: executing "sidebar" at <(index $thumbnail 0).Fill>: error calling Fill: image "/Users/okdyy75/hugo-theme-salt/content/article/hugo/fontawsome/thumbnail.png": this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information
Total in 235 ms

ローカルのhugoとhugo-binのバージョンを確認してみると

Hugoで一週間のPV数順の人気記事を作る方法

Hugoで一週間のPV数順の人気記事を作る方法

 Hugo
 2022-01-12

HugoとGoogle Analyticsを使って人気記事のランキングを作る方法を紹介します

ステップとしては

  1. GCPから鍵を作成し、Google Analyticsで権限を付与
  2. Google Analytics Data APIからpv数を取得するスクリプトを作成
  3. 保存したpvデータを元にHugoからランキング作成
  4. CIで定期的にpv取得スクリプトを起動させる

1. GCPから鍵を作成し、Google Analyticsで権限を付与

基本的にはdevelopers IOさんの記事を参考にします。「Google Analyticsでサービスアカウント用のユーザーに権限を与える」の部分まで実行してください。