fmt.Printf
Returns a string formatted according to the given format specifier.
- Syntax
- fmt.Printf FORMAT [INPUT]
- Returns
- string
- Alias
- printf
The documentation for Go’s fmt package describes the structure and content of the format string.
{{ $var := "world" }}
{{ printf "Hello %s." $var }} → Hello world.{{ $pi := 3.14159265 }}
{{ printf "Pi is approximately %.2f." $pi }} → 3.14Use the printf function with the safe.HTMLAttr 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">Last updated:
September 11, 2026
:
content: Comply with function/method description guidance in style guide (76fa3fc9e)
Improve this page