Hugo CSS Class

Does Hugo have something similar to Jekyll CSS Class?

No, there is no similar feature in Hugo.

Classes in HTML elements can be assigned directly in content files only through shortcodes, inline shortcodes or even raw HTML.

However the Markdown processor used by Hugo is CommonMark compliant and by default:

Goldmark does not render raw HTMLs and potentially dangerous links. If you have lots of inline HTML and/or JavaScript

Therefore you would need to set the unsafe flag in the project config:

unsafe= true

Understood. Let me use HTML for this. :sunglasses:

is that Markdown Attributes? Yes Hugo has something like that, the default is disabled.

Enable custom attribute support for titles and blocks by adding attribute lists inside single curly brackets ( {.myclass class="class1 class2" } ) and placing it after the Markdown element it decorates , on the same line for titles and on a new line directly below for blocks.

1 Like

@pamubay thanks for this!

I tried it in a markdown link and it adds the link to the <p> tag and not the <a> tag. I mostly need these classes in some <p> tags and link tags. But I will use the extra class feature instead.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.