How to enable line numbers by default, and override on some code blocks?

I am using hugo version v0.59.1 on Linux. I have hermit theme enable (pretty much latest I guess).

I tend to write a lot of code in my blog (I use code fences).
Most of them are source code, so there will be line numbers visible at the gutter.

And some code are output of the code. I use code fences for them as well. But I want no line numbers on them.

Where can I enable this setting from?

Have you looked in the documentation? It should be in there.

I went through this:

Looks like I have to do that on all of my code blocks? I can enable it globally?

I found it right away using the search:

I tried that prior to posting here. That is having no affect on the blocks.

It works, which must mean that

  1. your Hugo version is too old or
  2. your configuration is wrong. Which is hard to guess without seeing it.

I just figured out pygmentsOptions = "linenos=table" is essential in the config.

A comment on my 1) above: We reworked the highlighting config when we introduced Goldmark some time ago; old syntax still works, though.

I figured out how to enable line numbers, but how do I override it?


this isn’t working.

PS: I also figured out that installing Hugo from system repo lags too behind.

Any idea on how to override?

The above looks correct (from memory), which tells me that you probably run with an old Hugo version.

It was a caching issue. I verified in incognito mode.

Thanks, Erik for your time. :smiley:

1 Like