How to change id of headings?

I use a table of contents in every article. Sometimes I want a different anchor (id) for a specific heading. How can I achieve this?

Example

## My heading -> <h2 id="my-heading">My heading</h2>

Instead of id="my-heading" I want id="heading-1".

Is there a Markdown way of doing it or is

<h2 id="heading-1">My heading</h2>

the only solution?

You can use the following Markdown syntax:

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

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

ref: https://github.com/yuin/goldmark#headings

2 Likes

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