やりたいこと
Hugo 0.44まではビルドできたが、Hugo 0.45でビルドできない場合の修正方法です。
概要
Hugo 0.45から、.Site.GetPageの仕様が変わって、以下の制限が加わっています。
.Site.GetPage with more than 2 arguments will not work anymore. This means that {{ .Site.GetPage “page” “blog” “my-post.md” }} will fail.
手順
{{ .Site.GetPage "page" "blog" "my-post.md" }}
の場合は以下のようにして
書き換えられます。
- 0.44でも動く書き方:
{{ .Site.GetPage "page" "blog/my-post.md" }}
- 0.45以降のシンプルな書き方:
{{ .Site.GetPage "/blog/my-post.md" }}
変数を使う場合は、以下のような書き方でもいいと思います。
{{ .Site.GetPage "page" (print "blog" "/" $page) }}
{{ .Site.GetPage "page" (printf "blog/%s" $page) }}