# collections.Querify
> 根据给定的映射、切片或键值对序列，返回 URL 查询字符串。
- 官方英文原文：https://gohugo.io/functions/collections/querify/
- 本页规范地址：https://hugozh.cn/functions/collections/querify/
- 最近更新：2026-10-02
- 最后提交：912b1d3 chore(site): 添加 static/CNAME（hugozh.cn），供 GitHub Pages 等平台绑定自定义域名
- 签名：collections.Querify MAP|SLICE|KEY VALUE...
- 返回类型：string
- 站点：Hugo 中文文档（https://hugozh.cn/）· 社区维护的非官方中文翻译，如有出入以官方英文原文为准

---
把键值对指定为映射、切片，或者一串标量值。例如下面几种写法等价：

```go-html-template
{{ collections.Querify (dict "a" 1 "b" 2) }}
{{ collections.Querify (slice "a" 1 "b" 2) }}
{{ collections.Querify "a" 1 "b" 2 }}
```

要在 URL 后追加查询字符串：

```go-html-template
{{ $qs := collections.Querify (dict "a" 1 "b" 2) }}
{{ $href := printf "https://example.org?%s" $qs }}

<a href="{{ $href }}">Link</a>
```

Hugo 会把它渲染成：

```html
<a href="https://example.org?a=1&amp;b=2">Link</a>
```

你也可以传入项目配置或前置元数据中的映射。例如：

```toml
title = 'Example'
[params.query]
a = 1
b = 2
```

```go-html-template
{{ collections.Querify .Params.query }}
```

