Check for files present in static folder

Is there a way to check if a specific file is present in the static folder (say a header image for each content section)? fileExists does not seem to work.

If that is not possible, I would also be ok with adding the image to the root of the each section folder but haven’t figured out how to make that work.

This function should work for the static folder. Would you show us what you’ve tried so far?

1 Like

I guess we need to provide absolute path.

Does not work

{{ $path := "images/header.jpg" | relURL }}
{{ fileExists $path }}

Works

{{ $path := "static/images/header.jpg" }}
{{ fileExists $path }}

That is what the documentation implies:

You are correct.