Search code examples
markdownhugoblogdown

Inline html deleted from blogdown page


I have the following line of html code in a markdown (.md) file.

<a href="https://ocw.mit.edu/courses/sloan-school-of-management/15-401-finance-theory-i-fall-2008/#">Finance Theory I</a>

When I use blogdown to build the site, the text "Finance Theory I" is rendered without a hyperlink. I understand that I could use markdown hyperlinks instead. This is a simple example of a larger problem where none of my inline html is being rendered.


Solution

  • This is likely a side effect of Hugo adopting Goldmark as the default Markdown rendering library. This was introduced in Hugo v0.60.

    To have the Goldmark renderer emit HTML embedded in your Markdown add the following to your site config. This comes from the Hugo release notes linked above:

    [markup]
      [markup.goldmark]
        [markup.goldmark.renderer]
          unsafe = true
    

    Using this setting in a test site with your html and the ananke theme used in the initial Hugo walkthrough produced a link as expected with transformed markdown around it.