mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Merge commit 'f96384a3b596f9bc0a3a035970b09b2c601f0ccb'
This commit is contained in:
@@ -1,22 +1,15 @@
|
||||
---
|
||||
title: readFile
|
||||
description: Returns the contents of a file.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2021-11-26
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
parent: functions
|
||||
keywords: [files]
|
||||
signature: ["os.ReadFile PATH", "readFile PATH"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: ['os.FileExists','os.ReadDir','os.Stat']
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
The `os.ReadFile` function attempts to resolve the path relative to the root of your project directory. If a matching file is not found, it will attempt to resolve the path relative to the [`contentDir`]({{< relref "getting-started/configuration#contentdir">}}). A leading path separator (`/`) is optional.
|
||||
The `os.ReadFile` function attempts to resolve the path relative to the root of your project directory. If a matching file 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 a file named README.md in the root of your project directory:
|
||||
|
||||
@@ -38,4 +31,4 @@ This is **bold** text.
|
||||
|
||||
Note that `os.ReadFile` returns raw (uninterpreted) content.
|
||||
|
||||
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates]({{< relref "/templates/files" >}}).
|
||||
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates](/templates/files).
|
||||
|
Reference in New Issue
Block a user