DEV Community

Cover image for Syntax highlighting in Jekyll
Arjun Shetty
Arjun Shetty

Posted on • Edited on

2 1

Syntax highlighting in Jekyll

Here is a way to highlight your code on Jekyll site using the same Markdown syntax that github supports. I have been using github markdown day-in & day-out mostly with github gists.

To use the same markdown syntax for highlight the code syntax in your Jekyll site. First intall the rouge gem.

    gem install rouge
Enter fullscreen mode Exit fullscreen mode

Now in your _config.yml file

    markdown: kramdown
    highlighter: rouge
    kramdown:
      input: GFM
Enter fullscreen mode Exit fullscreen mode

The above setting sets kramdown as my markdown and for syntax highlighting use the rouge the gem you just installed. Also GFM says to use the Github Flavoured Markdown.

Now download the default css for the code styling from Github and copy to the css directory of your site and add the reference in _layout/default.html.

    <link rel="stylesheet" href="/css/syntax.css" type="text/css" />
Enter fullscreen mode Exit fullscreen mode

Done!

Image by Lorenzo Cafaro from Pixabay
Originally shared on Bitsmonkey Blog

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay