This is a very detailed guide on how to add syntax highlighting in Jekyll (Github Pages).
Basically, rouge
will slice the codes accordingly into separate HTML tags, the css will color it according to your theme. kramdown
is the Markdown processor supported in Github Pages. What I did on my Jekyll Bootstrap:
- Install
rouge
andkramdown
to generate css and render locally in the same manner as Github Pages.gem install kramdown rouge
- Update
_config.yml
markdown: kramdown highlighter: rouge kramdown: input: GFM #Github Flavored Markdown hard_wrap: false syntax_highlighter: rouge
- Create css file to color the syntax. I use the Bootstrap-3 theme.
rougify style monokai > assets/themes/bootstrap-3/css/syntax.css
- Add css link in
<head>
in_includes/themes/bootstrap-3/default.html
.<link href="/css/syntax.css" rel="stylesheet">
Jekyll 3.3.1 did not render the indented code block for numbered lists correctly. When I did bundle update
and was updated to jekyll 3.4.3, it showed up fine.