HUGO
News Docs Themes Community GitHub

urls.Decode

Returns the given URL-encoded string, decoded for display.

The urls.Decode function decodes a URL-encoded string back to its original form.

Example

Consider this front matter:

---
location: กรุงเทพ ไทย
title: A Forked of Hugo
---
+++
location = 'กรุงเทพ ไทย'
title = 'A Forked of Hugo'
+++
{
   "location": "กรุงเทพ ไทย",
   "title": "A Forked of Hugo"
}

Use the urldecode function to decode a URL-encoded string:

<header>
    <h1>{{ .Title }}</h1>
    {{ with .Params.location }}
        <div><a href="/locations/{{ urldecode ( . | urlize) }}">{{ . }}</a></div>
    {{ end }}
</header>

Hugo renders this to:

<header>
    <h1>A Forked of Hugo</h1>
    <div><a href="/locations/กรุงเทพ-ไทย">กรุงเทพ ไทย</a></div>
</header>

Last updated: January 1, 0001
Improve this page