有没有办法使用 Jekyll 注释掉 HTML 文件中的 include 语句?
例如,我的一个 HTML 文件中有此内容,我想暂时注释掉它。标准 HTML 注释似乎不起作用。
{% include navbar.html %}
{% comment %}
{% include navbar.html %}
{% endcomment %}
Jekyll 使用 Liquid 模板系统。因此,任何适用于 Liquid 的东西也适用于 Jekyll。
{% comment %}
this is commented out
{% endcomment %}
mccambridge 发布了正确的解决方案。 David Jacquel 发布的内容在 Jekyll 中不起作用。 或者,您可以在括号 { 和百分比符号 % 之间添加空格,如下所示:
{% comment %}
{ % include navbar.html % }
{% endcomment %}
由于 jekyll 在 html 中使用,我认为这样做更好
<div>
<!-- { % for i in (1..100) % } -->
{% for post in site.posts %}
<a href="{{post.url}}"> {{post.title}}</a>
{% endfor %}
<!-- { % endfor % } -->
</div>
上面的代码对我来说是一个非常常见的用例,我想模拟很多帖子来调试我的用户界面