HUGO

Is it possible to insert HTML code in Markdown content?

Does Hugo’s markdown engine support this feature? I haven’t got any clue on its documentation site. Any workarounds will be appreciated.

You can add html inside markdown files in /content. However your indented code will follow markdown formatting. You could also save your content files as .html but then you’ll have to write everything in html.

You can typically use HTML in Markdown. Hugo’s Markdown processor, Blackfriday merely adds a superset of functionality on top of Markdown. Hugo also has shortcodes that you can create (as well as some built-in) that might help too: https://gohugo.io/extras/shortcodes/

1 Like

@Billy_Herrington HTML can be part of markdown because HTML-inside-markdown is part of the spec. That said, remember that the spec disallows markdown nested inside of HTML. So if you create a div, just make sure everything inside that div is valid HTML. To echo @budparr, if you find yourself repeating blocks of HTML, it’s worth it to check out shortcodes.

1 Like

I inserted some HTML from Tableau Public into a post, and although I was eventually able to make it appear in the post, I noticed that the Recent Posts page shows the html as text. Is this expected?

Code: https://github.com/Leagify/quicktest/blob/master/content/posts/my-first-post.md#

Site: https://leagify.github.io/quicktest/

@Ross_Larson yes. The layout file responsible is: themes/ananke/layouts/post/summary.html

{{ .Summary }} strips all HTML tags.

See https://gohugo.io/content-management/summaries/

Create your own layouts/post/summary.html file to override the theme default.

I think this answers your question: https://anaulin.org/blog/hugo-raw-html-shortcode/