mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
809 B
809 B
title | description | categories | keywords | action | aliases | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
collections.Querify | Returns a URL query string composed of the given key-value pairs. |
|
|
Specify the key-value pairs as individual arguments, or as a slice. The following are equivalent:
{{ collections.Querify "a" 1 "b" 2 }}
{{ collections.Querify (slice "a" 1 "b" 2) }}
To append a query string to a URL:
{{ $qs := collections.Querify "a" 1 "b" 2 }}
{{ $href := printf "https://example.org?%s" $qs }}
<a href="{{ $href }}">Link</a>
Hugo renders this to:
<a href="https://example.org?a=1&b=2">Link</a>