mirror of
https://github.com/gohugoio/hugo.git
synced 2026-09-02 19:52:38 +00:00
810 B
810 B
title, description, categories, keywords, params, aliases
| title | description | categories | keywords | params | aliases | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| fmt.Printf | Formats a string using the standard `fmt.Sprintf` function. |
|
|
{{% include "/_common/functions/fmt/format-string.md" %}}
{{ $var := "world" }}
{{ printf "Hello %s." $var }} → Hello world.
{{ $pi := 3.14159265 }}
{{ printf "Pi is approximately %.2f." $pi }} → 3.14
Use the printf function with the safeHTMLAttr function:
{{ $desc := "Eat at Joe's" }}
<meta name="description" {{ printf "content=%q" $desc | safeHTMLAttr }}>
Hugo renders this to:
<meta name="description" content="Eat at Joe's">