# fmt.Erroridf
> 从模板记录一条可抑制的 ERROR 日志。
- 官方英文原文：https://gohugo.io/functions/fmt/erroridf/
- 本页规范地址：https://hugozh.cn/functions/fmt/erroridf/
- 最近更新：2026-10-02
- 最后提交：912b1d3 chore(site): 添加 static/CNAME（hugozh.cn），供 GitHub Pages 等平台绑定自定义域名
- 签名：fmt.Erroridf ID FORMAT [INPUT]
- 返回类型：string
- 站点：Hugo 中文文档（https://hugozh.cn/）· 社区维护的非官方中文翻译，如有出入以官方英文原文为准

---
Go 的 [`fmt`][] 包的文档描述了格式字符串的结构与内容。

[`fmt`]: https://pkg.go.dev/fmt

`erroridf` 函数对格式字符串求值，然后把结果输出到 ERROR 日志并使构建失败。与 [`errorf`][] 函数不同，你可以把消息 ID 加入项目配置的 `ignoreLogs` 数组，从而抑制 `erroridf` 函数记录的错误。

这段模板代码：

```go-html-template
{{ erroridf "error-42" "You should consider fixing this." }}
```

产生如下控制台日志：

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

要抑制这条消息：

```toml
ignoreLogs = ["error-42"]
```

[`errorf`]: /functions/fmt/errorf/

