使用Jekyll如何检查文件夹中是否存在文件?

使用Jekyll如何检查文件夹中是否存在文件?,jekyll,liquid,Jekyll,Liquid,我有一个\u includes文件夹,其中有nav子文件夹,其中包含一个nav.html文件 我一直在检查nav中是否存在nav.html。如果有,我想包括nav.html文件。如果它不存在,我的模板将有一个默认的nav 以下是我现在掌握的代码: {% for static_file in site.static_files %} {% if static_file.path == '/nav.html' %} {% include nav.html %} {%

我有一个
\u includes
文件夹,其中有
nav
子文件夹,其中包含一个
nav.html
文件

我一直在检查
nav
中是否存在
nav.html
。如果有,我想包括
nav.html
文件。如果它不存在,我的模板将有一个默认的
nav

以下是我现在掌握的代码:

{% for static_file in site.static_files %}
    {% if static_file.path == '/nav.html' %}
        {% include nav.html %}
    {% endif %}
{% endfor %}
希望你们能帮我


非常感谢您提前

我无法使用现有的液体标签找到解决方案,因此我使用带有自定义液体标签的插件解决了这个问题

{% capture fileExists %}{% file_exists _includes/nav/custom/nav.html %}{% endcapture %}
{% if fileExists=="true" %}
    {% include /nav/custom/nav.html %}
{% else %}
    {% include /nav/default/nav.html %}
{% endif %}