HUGO
Menu
GitHub 90473 stars Mastodon

fmt.Erroridf

Logs a suppressible ERROR from a template.
Syntax
fmt.Erroridf ID FORMAT [INPUT]
Returns
string
Alias
erroridf

Usage

The fmt.Erroridf function logs a suppressible ERROR from a template. The function formats INPUT according to FORMAT, writes the result to the ERROR log, and fails the build. The function returns an empty string.

The documentation for Go’s fmt package describes the structure and content of the format string.

Unlike the fmt.Errorf function, you can suppress errors logged by the fmt.Erroridf function. To suppress an error, add its ID to the ignoreLogs array in your project configuration. Hugo does not log a suppressed error, and the build does not fail.

Examples

{{ fmt.Erroridf "error-42" "You should consider fixing this." }}

The resulting console output:

ERROR You should consider fixing this.
You can suppress this error by adding the following to your project configuration:
ignoreLogs = ['error-42']

Suppressing the error in your project configuration:

ignoreLogs:
- error-42
ignoreLogs = ['error-42']
{
   "ignoreLogs": [
      "error-42"
   ]
}