If you need to show a piece of Liquid markup in a code sample in Jekyll, you need to escape it. The way to do it is to enclose it within another tag raw
and then end that with endraw
so that it is not interpreted as tags.
For example, you can see that the Liquid tags on Lines 2 and 4 are shown when we use it as below.
{% if page.mermaid %} ... the rest of the Javascript code from above ... {% endif %}
This is mainly written for me to remember what I need to do; if it helps someone, that’s great. Of course, feel free to share the post (you can tag me as @onghu on Twitter or on Mastodon as @onghu@ruby.social ) or leave a comment below.