Hugo function fileExists seems not working

Hi there,
I found fileExists function in document.I wanna use it but always get false even though file exist.

{{ if (fileExists  "static/images/avatar1.png") }}
  {{ printf "%#v" "aaaa" }}
{{  else if (fileExists "static/images/avatar2.png") }}
  {{ printf "%#v" "bbbb" }}
{{ else }}
  {{ printf "%#v" "cccc" }}
{{ end }}

This code always print “cccc”.
Has anyone ever used this function?

Your code works on my end. Something else is going on. You need to provide a sample repo of your project.

I thought the fileExists function follows the lookup order. For example, If I don’t have a file at root/static/images/avatar.png, Hugo would find the file automatically by searching at root/themes/zzo/static/images/avatar.png but that didn’t happen.
The function also works on my end when I put the file at root static folder.
Thank you for reply