Can we use highlight.js at server-side?

Currently I use highlight.js on client-side, the highlighting is great. But it always takes a little time to finish the highlight process, so everytime I refresh the page, there is a moment the code are raw and quite annoying. I see that Hexo use highlight.js internally, so I wonder if we can use highlight.js?

“Server side” rendering is currently only supported via Pygments.

@kevin5396: Nope, you can use pygment as @digitalcraftsman says. But highlight.js features lovely styles (monokai <3).
You can do a few things though. First, you can embed highlight.js only on pages that require it. That’s what I’m doing on my website, where few pages require highlighting:

{{ if .IsPage }} {{ if isset .Params "highlight" }}
      <script src="{{ "/js/" | absURL }}highlight.pack.js"></script>
{{ end }} {{ end }}

It’s very basic, as in my case there’s no need for more just yet. But it does the job, and I can add more conditions in the future without breaking anything.
I also got custom builds with only 1 or 2 languages available. That way, if I only need python highlighting on a page, I’ll add a variable highlight = “py” in the front matter. And I’ll use Go templates to load the right file ( This does 2 things in 1: no need to specify the language in the code blocks (in case highlight can’t detect it), and the js file is only 8.4kb big. You can grab custom builds on the official web: