How to prevent jekyll code running within markdown

2020-04-17 07:33发布

I was trying to add the following codes in a markdown code block on a Jekyll blog. However, the code within braces {% %} cannot be displayed.

{% for post in site.categories.[page.category] %}
{% if year != nyear %}
<p>{{ year }}</p>
{% endif %}

Anybody know how to prevent the codes within {% %} running? (I'm using markdown: kramdown in my _config.yml file).

1条回答
疯言疯语
2楼-- · 2020-04-17 07:59

You can use the raw tag.

{% raw %}
{% for post in site.categories.[page.category] %}
{% if year != nyear %}
<p>{{ year }}</p>
{% endif %}
...
{% endraw %}

This will render the liquid code as is.

查看更多
登录 后发表回答