From 87c539101dfb2228de08c448a93f3a370825f623 Mon Sep 17 00:00:00 2001 From: Lucas Westermann Date: Mon, 16 Apr 2018 10:07:54 +0200 Subject: [PATCH] Updated readFile documentation I've re-written the opening sentence to reflect the fact that the function checks multiple locations. I also added in a separate paragraph at the end to indicate that paths in error messages should be taken with a grain of salt. --- content/functions/readfile.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/functions/readfile.md b/content/functions/readfile.md index cb03ac551..bcd845c96 100644 --- a/content/functions/readfile.md +++ b/content/functions/readfile.md @@ -18,7 +18,7 @@ deprecated: false aliases: [] --- -Note that the filename must be relative to the current project working directory. +Note that the filename must be relative to the current project working directory, or the project's `/content` folder. So, if you have a file with the name `README.txt` in the root of your project with the content `Hugo Rocks!`: @@ -26,6 +26,8 @@ So, if you have a file with the name `README.txt` in the root of your project wi {{readFile "README.txt"}} → "Hugo Rocks!" ``` +If you receive a "file doesn't exist" error with a path listed, do take note that the path is the last one checked by the function, and may not accurately reflect your target. You should generally double-check your path for mistakes. + For more information on using `readDir` and `readFile` in your templates, see [Local File Templates][local]. [local]: /templates/files/