Table of Contents and Shortcodes

I created a shortcode to allow labels to be added to headings. The problem is when the TOC is generated it adds extra text to the TOC link, IE: HAHAHUGOSHORTCODE

Is there a way to have Hugo ignore this shortcode when generating the TOC? Are there other solutions around this? I want the label I am adding to show inline with the heading but not in the TOC.

The TOC is just an unordered list, so you can make a custom TOC that takes the generated TOC and then use replaceRE to remove the string, assuming that string is always the same or follows a pattern.

You could use the render heading hook

to store all in Scratch and generate anything from it.

Any chance you could share your repository? There are a few open GH issues related to the appearance of the “HAHAHUGOSHORTCODE” string, and I’d really like to look at your particular case.