Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With Hugo, can we use HTML code in a md file?

Tags:

hugo

With Hugo, I am writing some HTML as Goldmark markdown doesn't support CSS classes or IDs.

My code is in post1.md:

<h2 data-toggle="collapse" data-target="#collapse-definition" aria-expanded="false" aria-controls="collapse-definition">Définition</h2>

The above is not compiled to HTML. Even the simplest div markup is omitted.

like image 716
djibe Avatar asked Jan 24 '26 01:01

djibe


1 Answers

From version 0.6, Hugo uses Goldmark for markdown.

For security reasons, Goldmark wipes HTML code.

However, if you use HTML frequently in your site, you can add to your config.toml

[markup.goldmark.renderer]
  unsafe = true # Allow HTML in md files

For a less frequent usage of HTML, you can add safeHTML parameter to your HTML string (Hugo doc for safeHTML).

like image 122
djibe Avatar answered Jan 27 '26 01:01

djibe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!