diff --git a/content/en/functions/fmt/Errorf.md b/content/en/functions/fmt/Errorf.md index c23d27372..bbdd62c53 100644 --- a/content/en/functions/fmt/Errorf.md +++ b/content/en/functions/fmt/Errorf.md @@ -13,9 +13,9 @@ action: aliases: [/functions/errorf] --- -The documentation for [Go's fmt package] describes the structure and content of the format string. +{{% include "functions/fmt/_common/fmt-layout.md" %}} -Like the [`printf`] function, the `errorf` function evaluates the format string. It then prints the result to the ERROR log and fails the build. Hugo prints each unique message once to avoid flooding the log with duplicate errors. +The `errorf` function evaluates the format string, then prints the result to the ERROR log and fails the build. ```go-html-template {{ errorf "The %q shortcode requires a src parameter. See %s" .Name .Position }} @@ -24,5 +24,3 @@ Like the [`printf`] function, the `errorf` function evaluates the format string Use the [`erroridf`] function to allow optional suppression of specific errors. [`erroridf`]: /functions/fmt/erroridf -[`printf`]: /functions/fmt/printf -[Go's fmt package]: https://pkg.go.dev/fmt diff --git a/content/en/functions/fmt/Erroridf.md b/content/en/functions/fmt/Erroridf.md index a84671e3e..ae5b5c3e2 100644 --- a/content/en/functions/fmt/Erroridf.md +++ b/content/en/functions/fmt/Erroridf.md @@ -13,16 +13,14 @@ action: aliases: [/functions/erroridf] --- -The documentation for [Go's fmt package] describes the structure and content of the format string. +{{% include "functions/fmt/_common/fmt-layout.md" %}} -Like the [`errorf`] function, the `erroridf` function evaluates the format string, prints the result to the ERROR log, then fails the build. Hugo prints each unique message once to avoid flooding the log with duplicate errors. - -Unlike the `errorf` function, you may suppress errors logged by the `erroridf` function by adding the message ID to the `ignoreErrors` array in your site configuration. +The `erroridf` function evaluates the format string, then prints the result to the ERROR log and fails the build. Unlike the [`errorf`] function, you may suppress errors logged by the `erroridf` function by adding the message ID to the `ignoreErrors` array in your site configuration. This template code: ```go-html-template -{{ erroridf "error-42" "You should consider fixing this." }} +{{ erroridf "The %q shortcode was unable to find %s. See %s" .Name $file .Position }} ``` Produces this console log: @@ -40,4 +38,3 @@ ignoreErrors = ["error-42"] {{< /code-toggle >}} [`errorf`]: /functions/fmt/errorf -[Go's fmt package]: https://pkg.go.dev/fmt diff --git a/content/en/functions/fmt/Printf.md b/content/en/functions/fmt/Printf.md index af2fd398d..5d0127460 100644 --- a/content/en/functions/fmt/Printf.md +++ b/content/en/functions/fmt/Printf.md @@ -13,9 +13,7 @@ action: aliases: [/functions/printf] --- -The documentation for [Go's fmt package] describes the structure and content of the format string. - -[Go's fmt package]: https://pkg.go.dev/fmt +{{% include "functions/fmt/_common/fmt-layout.md" %}} ```go-html-template {{ $var := "world" }} diff --git a/content/en/functions/fmt/Warnf.md b/content/en/functions/fmt/Warnf.md index 02dc0b9c1..b07cf3cc3 100644 --- a/content/en/functions/fmt/Warnf.md +++ b/content/en/functions/fmt/Warnf.md @@ -13,13 +13,10 @@ action: aliases: [/functions/warnf] --- -The documentation for [Go's fmt package] describes the structure and content of the format string. +{{% include "functions/fmt/_common/fmt-layout.md" %}} -Like the [`printf`] function, the `warnf` function evaluates the format string. It then prints the result to the WARNING log. Hugo prints each unique message once to avoid flooding the log with duplicate warnings. +The `warnf` function evaluates the format string, then prints the result to the WARNING log. Hugo prints each unique message once to avoid flooding the log with duplicate warnings. ```go-html-template -{{ warnf "Copyright notice missing from site configuration" }} +{{ warnf "The %q shortcode was unable to find %s. See %s" .Name $file .Position }} ``` - -[`printf`]: /functions/fmt/printf -[Go's fmt package]: https://pkg.go.dev/fmt diff --git a/content/en/functions/fmt/_common/_index.md b/content/en/functions/fmt/_common/_index.md new file mode 100644 index 000000000..47d5812fb --- /dev/null +++ b/content/en/functions/fmt/_common/_index.md @@ -0,0 +1,13 @@ +--- +cascade: + _build: + list: never + publishResources: false + render: never +--- + + diff --git a/content/en/functions/fmt/_common/fmt-layout.md b/content/en/functions/fmt/_common/fmt-layout.md new file mode 100644 index 000000000..ff69ce5e4 --- /dev/null +++ b/content/en/functions/fmt/_common/fmt-layout.md @@ -0,0 +1,7 @@ +--- +# Do not remove front matter. +--- + +The documentation for Go's [fmt] package describes the structure and content of the format string. + +[fmt]: https://pkg.go.dev/fmt