Syntax error with {%- raw -%}


I am writing a post with code block with Liquid codes in it. So I am wrapping them in {% raw %} tag:

{%- raw -%}
{% include head.html %}
{%- endraw -%}

The hyphens are to strip whites-pace (two line breaks) that are inserted before and after the raw block, per:

But this generates syntax error:

Liquid Exception: Liquid syntax error (line 82): Tag '{%- raw -%}' was not properly terminated with regexp: /\%\}/

Is hyphens not supported with raw tag? Or am I doing something wrong here?

Thanks for answering.


You could put the raw tags on the same line to avoid the extra lines.

{% raw %}{% include head.html %}{% include head.html %}

Strange that the liquid docs mention it. Perhaps Jekyll is using a different version. I know there are some Shopify specific tags Jekyll doesn’t support, but this doesn’t seem to be the case.


This is a Liquid 4.0 feature slated to be available with Jekyll 3.5 and beyond.


Thanks. That’s what I end up doing. It messes up the code alignment. But oh well.