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

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

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

`errorf` 函数对格式字符串求值，然后把结果输出到 ERROR 日志并使构建失败。

```go-html-template
{{ errorf "The %q shortcode requires a src argument. See %s" .Name .Position }}
```

用 [`erroridf`][] 函数可以按需抑制特定的错误。

[`erroridf`]: /functions/fmt/erroridf/

