URL encoding/decoding

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!

urlquery is a predefined global function in Go’s template package, and has been documented for many years.

We added it the Hugo documentation last year:


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

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