liquid - Check for existence of file using Jekyll -
how can use jekyll test existence of file?
to clarify, want run {% if %}
statement check if image file exists same name page on.
on page in yaml front matter:
---- reference-design: true ----
in layout:
{% if page.reference-design %} {% assign filename = page.path | remove_first: '.html' %} <!-- how can check if file exists? --> <img src="images/reference_designs/{{ filename }}.png"> {% endif %}
as of jekyll 2, site files available via site.static_files
. can use check if file exists. example:
{% static_file in site.static_files %} {% if static_file.path == '/favicon.ico' %} {% assign favicon = true %} {% endif %} {% endfor %}
Comments
Post a Comment