Syntax highlighting with Chroma


#1

There are multiple ways to get syntax highlighting with Hugo. To name a few:

  • Use the original pygments library
  • Use JS, such as highlight.js
  • Use Chroma by way of a generated stylesheet
  • Use Chroma through the config file

I prefer the last way, since I find it the most simple… you only need 2 lines in your config file.

https://zwbetz.com/syntax-highlighting-in-hugo-with-chroma/


#2

I prefer the generated stylesheet, because I can more easily track down and manage style conflicts. But having 4 different options is nice!