I’m trying to check if a file exists, and if it does, display it in the template.
In my /layout/books/single.html I have:
{{ if (fileExists "cover.jpg") -}}
<img src="cover.jpg" />
{{- end }}
My content directory has:
/content/books/book-one/index.md
/content/books/book-one/cover.jpg
However the image isn’t displayed nor is the img tag present in view source. I’m not sure where the fileExists check will be relative to. The image file file does exist in the public directory
/public/books/book-one/cover.jpg
How can I conditionally display an image based on whether the file is there or not?