Switch between showing different programming languages in code blocks

Don’t know if this is primarily a support-question or a feature-request, but a very nice feature would be to switch between showing different programming languages in code blocks (see this).

I’m very new to hugo, but it would be a very nice feature to have for me. Do anyone have an idea for how I can implement this, or know if something like this can already be implemented? (I’d prefer not using the leetcode-proposition shown in the stack overflow post if possible).

The Hugo documentation does this in multiple locations, so you might just check its repo:

1 Like

as @bwintx mentioned,
look here for example:

{{< code-toggle file="config" >}}
[Params]
  foo = "bar"
{{< /code-toggle >}}

and shortcode https://github.com/gohugoio/hugoDocs/blob/master/layouts/shortcodes/code-toggle.html

This is designed for JSON, TOML, and YAML formats only.

1 Like

Perfect, thank you so much!

If you want to give AlpineJS a try (good match with Hugo), the shortcode above is ported to AlpineJS here:

1 Like