How to prevent jekyll code running within markdown code blocks

老子叫甜甜 提交于 2019-12-02 10:33:16

问题


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:


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.



来源:https://stackoverflow.com/questions/37170459/how-to-prevent-jekyll-code-running-within-markdown-code-blocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!