github.com/lyeb/hugo@v0.47.1/docs/content/en/functions/fileExists.md (about)

     1  ---
     2  title: "fileExists"
     3  linktitle: "fileExists"
     4  date: 2017-08-31T22:38:22+02:00
     5  description: Checks whether a file exists under the given path.
     6  godocref:
     7  publishdate: 2017-08-31T22:38:22+02:00
     8  lastmod: 2017-08-31T22:38:22+02:00
     9  categories: [functions]
    10  menu:
    11    docs:
    12      parent: "functions"
    13  signature: ["fileExists PATH"]
    14  workson: []
    15  hugoversion:
    16  relatedfuncs: []
    17  deprecated: false
    18  aliases: []
    19  ---
    20  
    21  `fileExists` allows you to check if a file exists under a given path, e.g. before inserting code into a template:
    22  
    23  ```
    24  {{ if (fileExists "static/img/banner.jpg") -}}
    25  <img src="{{ "img/banner.jpg" | absURL }}" />
    26  {{- end }}
    27  ```
    28  
    29  In the example above, a banner from the `static` folder should be shown if the given path points to an existing file.