我如何使用Jekyll来测试文件是否存在?
澄清一下,我想运行一个{% if %}
语句来检查是否存在与我所在页面同名的图像文件。
在我的页面的YAML前置元数据中:
----
reference-design: true
----
在我的布局中:{% if page.reference-design %}
{% assign filename = page.path | remove_first: '.html' %}
<!-- How can I check if file actually exists? -->
<img src="images/reference_designs/{{ filename }}.png">
{% endif %}
_includes
中,是否存在于集合中或者其他由Jekyll处理的文件确实有效。但是,它不适用于像资产这样的东西。 - vossad01