How to fix: Liquid Exception: Tag '{%' was not properly terminated with regexp: /\%\}/?
Asked Answered
S

4

8

I'm getting this output from my Jekyll website generator

Liquid Exception: Tag '{%' was not properly terminated with regexp: /\%}/

What's going on?

Slipon answered 23/3, 2013 at 11:26 Comment(0)
S
8

It turns out that you've probably made a formatting error in your template. For example:

{% if site.ALERT 
or site.ALERT_en %}

will break but

{% if site.ALERT or site.ALERT_en %}

is fine.

Slipon answered 23/3, 2013 at 11:26 Comment(1)
Thanks! This happened to a work colleague, however with the same setup it worked fine for me. Strange. Are there any settings or versions of npm/gem plugins that can effect the formatting rule? Does it specify this in the docs? I can see there examples are a single line wrapping but it doesn't specify you can't force wrap.Formulism
H
2

I had the issue with Octopress and the solution was to follow the advice by prigazzi:

The file that's causing this problem in octopress, is category_feed.xml, inside _includes/custom. You need to replace markdownify for markdownize and it works.

It did work for me.

Homochromous answered 16/9, 2014 at 20:46 Comment(0)
B
2

Jekyll may not properly tell you which included file the actual syntax error belongs in. For example, I got the same error telling me that my _layout/base.html had this error on line 5; but the syntax was fine: {% include head.html %}. The syntax of head.html was also fine; but it included another file (header.html) which had an incomplete {% for line that I was writing but didn't finish.

Basically... you may have to follow the breadcrumb trail until you get to your error.

Bret answered 20/9, 2016 at 1:45 Comment(0)
I
0

I got this error while updating this:

{%- assign img_url = product | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}

To this:

{{ product | img_url: '1x1' | replace: '_1x1.', '_{width}x.' }}

Error:

Liquid syntax error (line 7): Variable '{{ product | img_url: '1x1' | replace: '_1x1.', '_{width}' was not properly terminated with regexp: /\}\}/

I had to break it up into two steps. Removing the replace stopped the error, but moving the replace into the {{ }} tags causes it to come back.

{%- assign img_url = product | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
{{ img_url }}
Inquisitionist answered 6/2, 2023 at 5:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.