Using errorf or warnf within a render hook

I am using a render hook, specifically layouts/_default/_markup/render-image.html.

I need to call errorf under certain conditions.

When calling errorf or warnf within a shortcode I can indicate where the problem occurred with .Name and .Position.

When using errorf or warnf within a template I can use .Path.

These values are not available within a render hook. Any suggestions? I include an error code with the error message, so at least I know that the error is emitted by render-image.html, but I need to know the content page that triggered the problem.

Nevermind. This is documented. Thoroughly. :man_facepalming:

errorf "The problem is here: %s" .Page.File.Path

The problem is here: post/

1 Like

You have the Page so you can do .Page.Path etc.

A tip:


Is more robust, as not all pages are backed by a file.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.