From 3af715f7793c3937b88164c15c47bf4efb1f2f9b Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Mon, 11 Mar 2024 11:33:06 -0700 Subject: [PATCH] Clarify .Page.File behavior when page is not backed by a file --- content/en/methods/page/File.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/content/en/methods/page/File.md b/content/en/methods/page/File.md index a1c9478c3..310404cb8 100644 --- a/content/en/methods/page/File.md +++ b/content/en/methods/page/File.md @@ -22,7 +22,9 @@ content/ └── book-2.md ``` -Code defensively by verifying file existence as shown in each of the examples below. +{{% note %}} +Code defensively by verifying file existence as shown in the examples below. +{{% /note %}} ## Methods @@ -171,13 +173,7 @@ Some of the pages on a site may not be backed by a file. For example: - Taxonomy pages - Term pages -Without a backing file, Hugo will throw a warning if you attempt to access a `.File` property. For example: - -```text -WARN .File.ContentBaseName on zero object. Wrap it in if or with... -``` - -To code defensively, first check for file existence: +Without a backing file, Hugo will throw an error if you attempt to access a `.File` property. To code defensively, first check for file existence: ```go-html-template {{ with .File }}