# not
> 对唯一参数取布尔反。
- 官方英文原文：https://gohugo.io/functions/go-template/not/
- 本页规范地址：https://hugozh.cn/functions/go-template/not/
- 最近更新：2026-10-02
- 最后提交：912b1d3 chore(site): 添加 static/CNAME（hugozh.cn），供 GitHub Pages 等平台绑定自定义域名
- 签名：not VALUE
- 返回类型：bool
- 站点：Hugo 中文文档（https://hugozh.cn/）· 社区维护的非官方中文翻译，如有出入以官方英文原文为准

---
## 用法

与 `and`、`or` 运算符不同，`not` 运算符总是返回布尔值。

```go-html-template
{{ not true }} → false
{{ not false }} → true

{{ not 1 }} → false
{{ not 0 }} → true

{{ not "x" }} → false
{{ not "" }} → true
```

连续两次使用 `not` 运算符，可以把任意值转换为布尔值。例如：

```go-html-template
{{ 42 | not | not }} → true
{{ "" | not | not }} → false
```

更多信息参见 Go 的 [`text/template`](https://pkg.go.dev/text/template) 文档。

