# transform.HTMLUnescape
> 返回把每个 HTML 实体替换为对应字符后的给定字符串。
- 官方英文原文：https://gohugo.io/functions/transform/htmlunescape/
- 本页规范地址：https://hugozh.cn/functions/transform/htmlunescape/
- 最近更新：2026-10-02
- 最后提交：912b1d3 chore(site): 添加 static/CNAME（hugozh.cn），供 GitHub Pages 等平台绑定自定义域名
- 签名：transform.HTMLUnescape INPUT
- 返回类型：string
- 站点：Hugo 中文文档（https://hugozh.cn/）· 社区维护的非官方中文翻译，如有出入以官方英文原文为准

---
`transform.HTMLUnescape` 函数把 [HTML 实体][]替换为对应的字符。

```go-html-template
{{ htmlUnescape "Lilo &amp; Stitch" }} → Lilo & Stitch
{{ htmlUnescape "7 &gt; 6" }} → 7 > 6
```

在多数场景下，Go 的 [`html/template`][] 包会转义特殊字符。要绕过这一行为，请把未转义的字符串交给 [`safe.HTML`][] 函数。

```go-html-template
{{ htmlUnescape "Lilo &amp; Stitch" | safeHTML }}
```

[HTML 实体]: https://developer.mozilla.org/en-US/docs/Glossary/Entity
[`html/template`]: https://pkg.go.dev/html/template
[`safe.HTML`]: /functions/safe/html/

