Loading...

How to escape Liquid template code in a Jekyll website?

question liquid jekyll
Ram Patra Published on August 11, 2020

We know that Jekyll uses Liquid as its templating language. This means all your Liquid code will be executed by Jekyll by default.

So, if you want to embed Liquid code in your Jekyll website but don’t want Jekyll to process it then what are you going to do? What if you want to show a few code samples of Mustache or Handlebars in your Jekyll website? How do we prevent certain portions of code from being executed by Jekyll?

{% raw %} and {% endraw %} to the rescue.

Simply surround the code you don’t want to get executed with {% raw %} and {% endraw %} like below:

{% raw %}
    {% assign str="I only want to show this code" %}
{% endraw %}

In fact, this blog is made in Jekyll and I have used the same technique that I mentioned above to show you the liquid code.

Ram Patra Published on August 11, 2020
Image placeholder

Keep reading

If this article was helpful, others might be too

question liquid August 11, 2020 How to create an array in Liquid?

The official doc of Liquid doesn’t tell us a way tocreate an array except this:

question liquid August 11, 2020 How to check if a string is blank in Liquid?

I read the official docs of Liquid but couldn’t findthe info that I was looking for.