Enable raw HTML in Hugo
Hugo uses Goldmark as its default Markdown renderer, and Goldmark does not render raw HTML by default. If trusted content needs HTML that Markdown cannot express, enable it in your site configuration.
For a YAML configuration file, add:
markup:
goldmark:
renderer:
unsafe: true
The name unsafe is worth paying attention to. This setting allows raw HTML in every Markdown file rendered with that configuration, so I would only enable it when the people editing the content are trusted.
If only a few posts need custom markup, a shortcode can be a narrower and easier-to-maintain option.
Enjoyed reading this?
If you found this article helpful, consider supporting my writing. Every little bit helps keep this blog going.
Related articles
- When to Use Hugo Shortcodes or Render Hooks
Use render hooks to change normal Markdown output and shortcodes for custom content with meaning Markdown cannot express.
- Customizing Hugo’s RSS Feed
Adjust Hugo RSS titles, descriptions, content, and section filtering while keeping the generated feed valid and easy to discover.
- Organizing Hugo Content With Tags and Categories
Organize Hugo content with a small, deliberate set of tags, categories, or custom taxonomies that lead to useful archive pages.