Set custom classes within Markdown content

In Jekyll, you’re able to set custom classes for sections within Markdown itself.

For example, if I wanted to add a special ‘warning’ class to a block quote I could do:

> Beware!

{: .warning}

And it would render into

<blockquote class="warning">

Is something similar possible within Hugo?

You should look into Hugo shortcodes. Be aware Hugo does not process shortcodes in frontmatter only the main content of a .md doc. That threw me off for a while.

You could do something like

{{<warning "beware" "Beware!">}}

and have shortcode called warning.html

<blockquote class="{{ .Get 0 }}">
  {{ .Get 1 }}

Hugo has moved to Goldmark as default Markdown processor.
And as per today Goldmark supports adding classes, id and custom attributes to heading only. With more to come in future.

## heading ## {#id .className attrName=attrValue class="class1 class2"}

## heading {#id .className attrName=attrValue class="class1 class2"}

You can read about goldmark custom attribute support on their github readme.