os.FileExists
Reports whether the file or directory exists.
- Syntax
- os.FileExists PATH
- Returns
- bool
- Alias
- fileExists
The os.FileExists function attempts to resolve the path relative to the root of your project directory. If a matching file or directory is not found, it will attempt to resolve the path relative to the contentDir. A leading path separator (/) is optional.
With this directory structure:
content/
├── about.md
├── contact.md
└── news/
├── article-1.md
└── article-2.mdThe function returns these values:
{{ fileExists "content" }} → true
{{ fileExists "content/news" }} → true
{{ fileExists "content/news/article-1" }} → false
{{ fileExists "content/news/article-1.md" }} → true
{{ fileExists "news" }} → true
{{ fileExists "news/article-1" }} → false
{{ fileExists "news/article-1.md" }} → trueLast updated:
June 18, 2026
:
Merge commit 'c86d9f4aa8a58931f52df6516f10b67c807505fb' (be780afa7)
Improve this page