How to turn off smart quotes in Jekyll?

When I first started this blog, I noticed that my quotes (single and double) were "smart quotes" or as I like to refer to them "fancy quotations".

For example:

Image showing how smart quotes look

Since my blog has a lot of programming articles, I didn't want to have smart quotes as it messes up people's ability to copy and paste code from my site.

How to turn off smart quotes in Jekyll?

Since Kramdown is the default Markdown renderer for Jekyll, it is what I am using and what you are likely using too.

Kramdown by default uses smart quotes (check out the Kramdown documentation here).

To turn off fancy quotes in Jekyll do the following:

  1. Open your _config.yml file

  2. You should have a kramdown option that looks like this:

     kramdown:
         input: GFM
         auto_ids: true
         hard_wrap: false
         syntax_highlighter: rouge
    

    The important thing to notice is it likely doesn't have the smart_quotes option defined - meaning it is using the default one. So in the next step, we will add the option to disable the smart quotes in Jekyll.

  3. Add this option so that kramdown knows not to use smart quotes or single quotes:

       smart_quotes: ["apos", "apos", "quot", "quot"]
    

    So in the end it should look something like so:

     kramdown:
         input: GFM
         auto_ids: true
         hard_wrap: false
         syntax_highlighter: rouge
         smart_quotes: ["apos", "apos", "quot", "quot"]
    

    See:

Image of how config.yml will look like when disabling smart quotes

That's it, smart quotes should now be turned off in Jekyll.


This works because the first two "apos" replaces the smart single quote with a regular single quote apostrophe and the last two "quot" replaces the smart double quotes with regular quotes.

I hope you now know how to remove smart quotes in Jekyll.

Make one page websites quickly using my Carrd Templates