Thanks for the tip! This is a fairly common support question when setting up a Hugo site on CloudCannon, and it’s great to see it mentioned here with the solution.
In many other SSGs, using raw HTML in Markdown files is enabled by default. It’s not much of a safety barrier here as someone could add HTML to non-Markdown files regardless. It’s also worth noting our Rich Text Editors don’t allow arbitrary HTML unless configured through Snippets or the embed
option.
Here’s some context: we’ll save links in Markdown format wherever possible, but as you’ve found, they’re sometimes saved as HTML.
Links in Markdown output to anchor <a>
elements in HTML, and anchor elements have attributes that sometimes cannot be preserved using Markdown alone. Users can add these attributes to links during editing.
Here’s an example anchor element that opens in a new tab/window, has a title hover-tooltip, and tells the browser not to send the Referer header:
<a href="https://cloudcannon.com/"
title="The CloudCannon home page"
target="_blank"
rel="noreferrer">CloudCannon</a>
Standard CommonMark-style (which Hugo/Goldmark is based on) has no way to keep the attributes other than title
, so saving it as Markdown would remove them:
[CloudCannon](https://cloudcannon.com/ "The CloudCannon home page")
For those not using Hugo:
Kramdown,
markdown-it (with extension), and other Markdown processors support attribute lists, meaning we can preserve these attributes here without falling back to HTML. CloudCannon supports several Markdown attribute list formats as well.
[CloudCannon](https://cloudcannon.com/ "The CloudCannon home page"){: target="_blank" rel="noreferrer" }
If attribute lists are not available, and links have attributes that would otherwise be lost, we save them as HTML within the Markdown file.