# URL encoding/decoding

**URL:** <https://discourse.gohugo.io/t/url-encoding-decoding/43148>\
**Category:** support\
**Created:** [February 24, 2023, 5:24pm UTC](https://discourse.gohugo.io/t/url-encoding-decoding/43148 "2023-02-24T17:24:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![musthero](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/musthero/32/18158_2.png) [@musthero](https://discourse.gohugo.io/u/musthero)\
**Post date:** [February 24, 2023, 5:24pm UTC](https://discourse.gohugo.io/t/url-encoding-decoding/43148/1 "2023-02-24T17:24:05Z")

</div>

Is there a function to encode some text to make it URL safe (i.e. replacing spaces be with “%20”)?

Someone has already posted earlier that there is undocumented function **urlquery** , but the mere fact it is undocumented makes me feel uncomfortable in using it. Also it was a few years ago.

Otherwise, {{ urlquery .Params.mytext }} works just fine for me!

May thanks!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 24, 2023, 5:48pm UTC](https://discourse.gohugo.io/t/url-encoding-decoding/43148/2 "2023-02-24T17:48:42Z")

</div>

`urlquery` is a predefined global function in Go’s template package, and has been documented for many years.  
[https://pkg.go.dev/text/template#hdr-Functions](https://pkg.go.dev/text/template#hdr-Functions)

We added it the Hugo documentation last year:  
[https://gohugo.io/functions/urlquery/](https://gohugo.io/functions/urlquery/)

---

<div class="post-metadata">

**Author:** ![musthero](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/musthero/32/18158_2.png) [@musthero](https://discourse.gohugo.io/u/musthero)\
**Post date:** [February 24, 2023, 6:40pm UTC](https://discourse.gohugo.io/t/url-encoding-decoding/43148/3 "2023-02-24T18:40:51Z")

</div>

Oh, I see… Thank you very much, @jmooring

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [February 26, 2023, 6:41pm UTC](https://discourse.gohugo.io/t/url-encoding-decoding/43148/4 "2023-02-26T18:41:18Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
