Markup Matryoshka: Jinja2 inside of Jekyll

Have you ever tried to write a Jekyll blog post with Jinja2 code inside of it? You probably wrote something like this:

{% highlight awk %}

{% raw %}
{% highlight awk %}
This Jinja2 code is going to be soooooooooo {{ adjective }}
{% endhighlight %}
{% endraw %}

{% endhighlight %}

Which probably actually rendered to something like this:

{% raw %}
{% highlight awk %}
This Jinja2 code is going to be soooooooooo
{% endhighlight %}
{% endraw %}

{% endhighlight %}

It’s going to be soooooo? Sooooo what?!

So what?

Solution: just use the {% raw %} and {% endraw %} tags:

This Jinja2 code is going to be soooooooooo {% raw %}  {{ adjective }}  {% endraw %}

Now, how did we insert inline {% raw %} and {% endraw %} tags without Jekyll choking on them? You’ll just have to check out the source for this post on our Jekyll blog’s GitHub.

Comments are closed.