Liquid Tag {% raw %}{% endraw %}
in Jekyll
Jekyll uses the Liquid template language to process templates1, and2:
Liquid uses a combination of objects, tags, and filters inside template files to display dynamic content.
where tags and filters are special syntax, and they are wrapped in {% %}
and {{ }}
, respectively:
Tags create the logic and control flow for templates. The curly brace percentage delimiters {%
and %}
and the text that they surround do not produce any visible output when the template is rendered. This lets you assign variables and create conditions or loops without showing any of the Liquid logic on the page.1
Filters change the output of a Liquid object or variable. They are used within double curly braces {{ }}
and variable assignment, and are separated by a pipe character |
.1
So, every {{
and {%
in the Markdown source file will be viewed as the symbol of Liquid tag and Liquid filter. If we use them without paying attention — if our intention is not using a Liquid syntax — then a Liquid syntax error will occur when compiling the website.
For example, I have seen that many LaTeX users use a comment mark %
after the curly brace {
to avoid additional and unexpected blank space, like the example in my previous blog3:
So, when we write such LaTeX code in the Markdown file, then Jekyll will throw a Liquid syntax error breaking the compilation.
To avoid this kind of error, we could put the content that includes {{
and {%
in the {% raw %}
tag:
1
2
3
4
5
{% raw %}
content...
{% endraw %}
Outputs text as is, useful if your template contains Liquid syntax. Virtually identical in effect to the literal tag.4
To make things easier, we can add {% raw %}
at the beginning of the Markdown file (but after the Front Matter), and {% endraw %}
at the end of the file.
But bear in mind that, we can’t directly use {% raw %}
again in the range of {% raw %} {% endraw %}
, otherwise which may induce other unexpected results. If have to, we should rely on the Liquid syntax introduced in the blog5. It is the way that this blog used:
References