Asciidoctor Hugo
Hugo has great support for Markdown. It works out-of-the-box altogether. However, I like Asciidoc more so I tried to set up the platform for writing pages with lots of source code listings. It became a task for masochists. If you are okay with Markdown, you should probably stay in that realm and enjoy simplicity.
I tried several approaches. None of them seemed to work for me.
- External CSS according to Rgielen.net - There is also a hint for admonitions
- Use Hugo Shortcodes
What helped in the end, was rendering the source code highlights directly with Asciidoctor and embedding the styles into html tags. I found this article and basically followed the steps with several modifications.
Hugo launches asciidoctor in default settings so the code syntax highlighting does not work. There is however a workaround. You need to 'hack' the asciidoctor launcher. Create a file called asciidoctor in the Hugo project root and then set the $PATH to look for this file.
I have set up the syntax highlighting to pygments with monokai style. Choose whatever style suits you and your page.
Don’t forget to set the execute permissions
chmod u+x asciidoctor
Set up the Path so that the custom asciidoctor is looked up first.
Make the script executable.
chmod u+x launch-hugo-server
Now you can call ~/wherever/my/project/is/launch-hugo/server
to start the hugo server and live-view the rendered pages.
If you would like just to build the pages without serving them, modify the script accordingly.