Is it possible to override the highlight shortcode template?

First, let me explain what I want to do and then what I already know. It is simple, I want to add a header with the language name in code blocks, also add a copy-to-clipboard button. I know I can use CSS ::before rules and JS to do that, but why use JS if I can change the template, right?

Looking at Hugo’s source code, it seems the highlight shortcode calls an internal function with the same name (Am I right?). So, there is no easy to override template here, I guess.

There is an easy way to override the code highlight feature that I’m not aware? Should I make a custom shortcode for that? if so, where do I find a complete version of the highlight template? Or should we and this kind of feature directly into Hugo, something like linenos and other already present highlight features?

Everything in layouts/shortcodes overrides internal shortcodes. Name it highlight.html and Hugo will use your own shortcode. This works NOT for the backticks, only for the {{<highlight>}} shortcode itself.

Edit: By the way, the internal shortcodes and templates are here:

2 Likes

Thanks, @davidsneighbour.

So, it is almost the same if I create a new shortcode.