Hugoのマークダウンで書かれたブログ記事の中に直接HTMLを書く方法を紹介します。
1. 実行環境
- Hugo:0.153.0
- Homebrew:5.0.6
- MacBook Pro (13-inch, 2020)
- macOS:Tahoe 26.1
2. 方法
マークダウン中にHTMLを含めるとデフォルトでは以下のエラーが出ます。
$ hugo server 省略 WARN Raw HTML omitted while rendering "/home/user/project/content/example.md"; see https://gohugo.io/getting-started/configuration-markup/#rendererunsafe You can suppress this warning by adding the following to your site configuration: ignoreLogs = ['warning-goldmark-raw-html']
hugo.yamlに以下を追加
markup:
goldmark:
renderer:
unsafe: true
これによって生のHTMLが表示されるようになります。
【参考】