transform.Remarshal
Returns a string of serialized data in the specified format, marshaled from a string of serialized data or a map.
- Syntax
- transform.Remarshal FORMAT INPUT
- Returns
- string
Usage
The transform.Remarshal function returns a string of serialized data in the specified format, marshaled from a string of serialized data or a map.
The FORMAT must be one of json, toml, yaml, or xml. If the INPUT is a string of serialized data, it must be valid JSON, TOML, YAML, or XML.
This function is primarily a helper for Hugo’s documentation, used to convert configuration and front matter examples to JSON, TOML, and YAML.
This is not a general-purpose converter, and may change without notice if required for Hugo’s documentation site.
Examples
{{ $s := `
baseURL = 'https://example.org/'
locale = 'en-US'
title = 'ABC Widgets'
`}}
<pre>{{ transform.Remarshal "json" $s }}</pre>The raw HTML output:
<pre>{
"baseURL": "https://example.org/",
"locale": "en-US",
"title": "ABC Widgets"
}
</pre>The rendered result in a browser:
{
"baseURL": "https://example.org/",
"locale": "en-US",
"title": "ABC Widgets"
}Converting a map to YAML:
{{ $m := dict
"a" "Hugo rocks!"
"b" (dict "question" "What is 6x7?" "answer" 42)
"c" (slice "foo" "bar")
}}
<pre>{{ transform.Remarshal "yaml" $m }}</pre>The raw HTML output:
<pre>a: Hugo rocks!
b:
answer: 42
question: What is 6x7?
c:
- foo
- bar
</pre>The rendered result in a browser:
a: Hugo rocks!
b:
answer: 42
question: What is 6x7?
c:
- foo
- barLast updated:
October 21, 2026
:
content: Apply style guide to transform functions (3625f720a)
Improve this page