hugo/content/en/functions/urlize.md
Bjørn Erik Pedersen 7d7771b673 Squashed 'docs/' changes from 7297c1172..d3eb97a33
d3eb97a33 Document .IsSection page variable
a068bcf5c Ace and Amber support was removed with #6609
5cd9ca4b2 Mention MacPorts also on the Installing page  (#1215)
0ae8f5c19 Add instructions for using Macports
d50aba8f0 Revise ref and relref function pages
a17e25d6f Update quick-start.md: move notice about drafts up
cf87a5da2 Update macOS tarball installation instructions (#1203)
2e701f8f3 Corrected the url for index function link
736bd59e0 Clarify treatment of zero weights (#1207)
42a19f479 Fix example of output from urlize function
34f8de26d Revise content-management/cross-references
252435a95 Rewrite Translation of Strings
f0882bc14 Remove note that has been outdated by v0.71.0
dfe28ceb5 Improve mounts module config
58029627d Fix erroneous example code piping to if

git-subtree-dir: docs
git-subtree-split: d3eb97a3328f5390801bbce017233ce895fc2d28
2020-09-07 21:37:51 +02:00

1.9 KiB

title description date publishdate lastmod categories menu keywords godocref signature hugoversion deprecated workson relatedfuncs
urlize Takes a string, sanitizes it for usage in URLs, and converts spaces to hyphens. 2017-02-01 2017-02-01 2017-02-01
functions
docs
parent
functions
urls
strings
urlize INPUT
false

The following examples pull from a content file with the following front matter:

{{< code file="content/blog/greatest-city.md" copy="false">}} +++ title = "The World's Greatest City" location = "Chicago IL" tags = ["pizza","beer","hot dogs"] +++ {{< /code >}}

The following might be used as a partial within a single page template:

{{< code file="layouts/partials/content-header.html" download="content-header.html" >}}

{{.Title}}

{{ with .Params.location }}
{{.}}
{{ end }} {{ with .Params.tags }}
    {{range .}}
  • {{ . }}
  • {{end}}
{{ end }} {{< /code >}}

The preceding partial would then output to the rendered page as follows, assuming the page is being built with Hugo's default pretty URLs.

{{< output file="/blog/greatest-city/index.html" >}}

The World's Greatest City

{{< /output >}}