Search code examples
githubjekyllgithub-actions

Build with Jekyll failed because of unknown tag


I fork a blog repository on Github with JekylI and push my article to the _post folder.
I attached the macro code for Jinja2 to the article as below

{% macro -%}

However the github actions "pages build and deployment" is failed because of the build stage threw an exception

Liquid Exception: Liquid syntax error (line 69): Unknown tag 'macro' in

I tried to increment "\" before "%" like this and Jekyll build success

{\% macro -\%}

But "\" is also displayed in the article

I also tried to fork other Jekyll repository, the phenomenon is the same, so I think it is jekyll build problem

Can anyone help me? Thank you very much for any advice


Solution

  • The problem is {} in the code are identified by Jekyll as Liquid code.
    Add {% raw %} and {% endraw %} to tell Jekyll not to treat the content as Liquid code

    {% raw %}
    {% macro -%}
    {% endraw %}