Search code examples
jekyllblogsliquid

how to displayliquid code in Jeckyll post


Hello I am trying to make a post using jeckyll and as part of my post I would like to show some liquid code. The post should display the IF statement as part of the post text (example below).

{% if customer and customer.tags contains 'Wholesale'  %}
{% endif %}

I have tried to post this as

{% highlight liquid %}
   {% if customer and customer.tags contains 'Wholesale'  %}
   {% endif %}
{% endhighlight %}

and also

{% highlight markdown %}
    {% if customer and customer.tags contains 'Wholesale'  %}
    {% endif %}
{% endhighlight %}

but anything I try seems to be still executing the liquid code. Is there a way to display the IF statement my post?


Solution

  • Try wrapping your liquid code in {% raw %} {% endraw %} like this:

    {% highlight liquid %}
        {% raw %}
        {% if customer and customer.tags contains 'Wholesale'  %}
        {% endif %}
        {% endraw %}
    {% endhighlight %}
    

    The raw tag will disable any liquid processing and output your code as desired.