Adding multiple CSS classes to an anchor link

I’m using anchor links in my .markdown document like so:

# {#infrared}

This works fine but I wanted to implement the following CSS so that the link scrolls to the middle of the page and not at the top:

.anchor {
  position: absolute;
  transform: translateY(-50vh);

How can I add the class anchor to my anchor link in the markdown document?

If I understand the question, you are asking for a way to add multiple classes in anchor links in Markdown.

As per the README of Goldmark the Markdown processor that is currently turned on by default in Hugo:

Currently only headings support attributes…

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

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

Oh wow I didn’t know this was supported. Thank you so much, this fixes my issue.

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