Hugo Tips
目次
私がよく使った検索キーワード
- Front Matter
タグやカテゴリーはconfig.tomlに以下を指定しないと動きません
[taxonomies]
tag = "tags"
category = "categories"
ジェネレートして公開!
と思いきや、ジェネレートでエラーが・・・。
% hugo
WARN 2022/05/10 01:48:18 Module "ananke" is not compatible with this Hugo version; run "hugo mod graph" for more information.
Start building sites …
Total in 87 ms
Error: Error building site: render of "404" failed: execute of template failed: template: 404.html:1:24: executing "header" at <partial "page-header.html" .>: error calling partial: execute of template failed: template: partials/page-header.html:23:9: executing "partials/page-header.html" at <partial "site-navigation.html" .>: error calling partial: "layouts/partials/site-navigation.html:3:21": execute of template failed: template: partials/site-navigation.html:3:21: executing "partials/site-navigation.html" at <.Site.Home.RelPermalink>: error calling RelPermalink: runtime error: invalid memory address or nil pointer dereference
これ、少しハマりましたが、原因はcontentディレクトリ直下のindex.mdがドラフト状態だった(draft: true)になっていたことが原因でした。 フォーラムで同じようなエラーの質問している人がいたけど、よくわかんなかったから新規構築して工程を順番に確認していきました。 Hugoはこの辺がサクッとできていいですね。
Googleアナリティクス設定
あれっ。Google Analyticsの対応って、ちょっと一手間? config.tomlにgoogleAnalyticsってい便利そうなパラメーターがあるから、それを使えばと思いきや、最新のgtag.jsには対応していない模様。 (古いタイプのanalytics.jsを使う場合はこちらで問題ない)
META NAME=“ROBOTS” CONTENT=“NOINDEX, NOFOLLOW”
% HUGO_ENV="production" hugo
production指定でジェネレイト。これで対応。
参考
https://qiita.com/momotaro98/items/4de7934fd79cd6b34fce
https://knowledge.sakura.ad.jp/22908/