CMSからの追加テスト

2020-07-15 netlify Troubleshooting netlify

現象

netlify CMS経由で追加したファイルがデプロイに失敗していた。

render of “page” failed: execute of template failed: template: _default/single.html:3:5: executing “_default/single.html” at <partial “head” .>: error calling partial: execute of template failed: template: _internal/schema.html:22:82: executing “_internal/schema.html” at <.Params.tags>: range can’t iterate over session

エラー自体はテンプレートからのビルドで表示されているようで特定に時間がかかった。

修正内容

netlify CMSの config.yml に誤りがあった。tag, categoryのwidgetの指定をstringにしていたのでlist形式に修正した。

本記事は修正確認のための投稿でもある。

参考URL: https://www.netlifycms.org/docs/widgets/

config.yml修正前

- {label: "tag", name: "tags", widget: "string", default: "blog"}
- {label: "category", name: "categories", widget: "string", default: "blog"}

hugoが作成するFront Matter

title: "hogehoge"
tags: "blog"
categories: "blog"

config.yml修正後

- {label: "tag", name: "tags", widget: "list", default: ["blog"]}
- {label: "category", name: "categories", widget: "list", default: ["blog"]}

hugoが作成するFront Matter

title: "hogehoge"
tags: 
- blog
categories: 
- blog