2019-10-21 10:22:28 +02:00
---
title: querify
linktitle: querify
2021-05-10 08:18:37 -07:00
description: Takes a set or slice of key-value pairs and returns a query string to be appended to URLs.
2019-10-21 10:22:28 +02:00
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [urls]
godocref:
2021-05-10 08:18:37 -07:00
signature: ["querify KEY VALUE [KEY VALUE]...", "querify COLLECTION"]
2019-10-21 10:22:28 +02:00
hugoversion:
deprecated: false
workson: []
relatedfuncs: []
aliases: []
---
2021-05-10 08:18:37 -07:00
`querify` takes a set or slice of key-value pairs and returns a [query string ](https://en.wikipedia.org/wiki/Query_string ) that can be appended to a URL.
2019-10-21 10:22:28 +02:00
2021-05-10 08:18:37 -07:00
The following examples create a link to a search results page on Google.
2019-10-21 10:22:28 +02:00
2021-05-10 08:18:37 -07:00
```go-html-template
2019-10-21 10:22:28 +02:00
<a href="https://www.google.com?{{ (querify "q" "test" "page" 3) | safeURL }}">Search</a>
2021-05-10 08:18:37 -07:00
{{ $qs := slice "q" "test" "page" 3 }}
<a href="https://www.google.com?{{ (querify $qs) | safeURL }}">Search</a>
2019-10-21 10:22:28 +02:00
```
2021-05-10 08:18:37 -07:00
Both of these examples render the following HTML:
2019-10-21 10:22:28 +02:00
2021-05-10 08:18:37 -07:00
```html
2019-10-21 10:22:28 +02:00
<a href="https://www.google.com?page=3&q=test">Search</a>
```