mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
``` git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash ``` Closes #11925
This commit is contained in:
41
docs/content/en/functions/os/FileExists.md
Normal file
41
docs/content/en/functions/os/FileExists.md
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
title: os.FileExists
|
||||
description: Reports whether the file or directory exists.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [fileExists]
|
||||
related:
|
||||
- functions/os/Getenv
|
||||
- functions/os/ReadDir
|
||||
- functions/os/ReadFile
|
||||
- functions/os/Stat
|
||||
returnType: bool
|
||||
signatures: [os.FileExists PATH]
|
||||
aliases: [/functions/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`](/getting-started/configuration#contentdir). A leading path separator (`/`) is optional.
|
||||
|
||||
With this directory structure:
|
||||
|
||||
```text
|
||||
content/
|
||||
├── about.md
|
||||
├── contact.md
|
||||
└── news/
|
||||
├── article-1.md
|
||||
└── article-2.md
|
||||
```
|
||||
|
||||
The function returns these values:
|
||||
|
||||
```go-html-template
|
||||
{{ 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" }} → true
|
||||
```
|
Reference in New Issue
Block a user