safe.HTML
Returns the given string declared as safe HTML.
- Syntax
- safe.HTML INPUT
- Returns
- template.HTML
- Alias
- safeHTML
Usage
The safe.HTML function returns the given string declared as safe HTML. Use it with a known safe HTML document fragment. Do not use it with HTML from a third party, or with HTML that has unclosed tags or comments. See the Go documentation for details.
Only use this function with content from a trusted source, because Hugo does not check the content for unsafe values. See safe types for an explanation of how Hugo escapes values, and how each safe data type affects escaping.
Examples
{{ safe.HTML "<em>emphasized</em>" }} → <em>emphasized</em>Comparing the result with and without safe.HTML, showing the raw HTML output:
{{ "<em>emphasized</em>" }} → <em>emphasized</em>
{{ "<em>emphasized</em>" | safe.HTML }} → <em>emphasized</em>Last updated:
October 27, 2026
:
content: Clarify partial and template functions (#3746) (b5ac2f006)
Improve this page