# encoding.Base64Decode
> 返回给定内容的 base64 解码结果。
- 官方英文原文：https://gohugo.io/functions/encoding/base64decode/
- 本页规范地址：https://hugozh.cn/functions/encoding/base64decode/
- 最近更新：2026-10-02
- 最后提交：912b1d3 chore(site): 添加 static/CNAME（hugozh.cn），供 GitHub Pages 等平台绑定自定义域名
- 签名：encoding.Base64Decode INPUT
- 返回类型：string
- 站点：Hugo 中文文档（https://hugozh.cn/）· 社区维护的非官方中文翻译，如有出入以官方英文原文为准

---
```go-html-template
{{ "SHVnbw==" | base64Decode }} → Hugo
```

用 `base64Decode` 函数可以解码 API 的响应。例如，调用 GitHub API 得到的响应中，包含仓库 README 文件的 base64 编码表示：

```text
https://api.github.com/repos/gohugoio/hugo/readme
```

要取回并渲染其中的内容：

```go-html-template
{{ $url := "https://api.github.com/repos/gohugoio/hugo/readme" }}
{{ with try (resources.GetRemote $url) }}
  {{ with .Err }}
    {{ errorf "%s" . }}
  {{ else with .Value }}
    {{ with . | transform.Unmarshal }}
      {{ .content | base64Decode | markdownify }}
    {{ end }}
  {{ else }}
    {{ errorf "Unable to get remote resource %q" $url }}
  {{ end }}
{{ end }}
```

