Recently, Hugo received XML data support
See Implement XML data support · gohugoio/hugo@0eaaa8f · GitHub
I’m trying to get it to work. I have a .xml
file in my /data
folder and want to iterate over tags. That works. For instance, getting the contents of <title>blah</title>
indeed is simple: {{ $.Site.Data.myfile.head.title }}
.
But what about attributes? Printing the raw value using {{ . }}
to peek inside the Go vars gives me something akin to map[-text:Blogging -title:Blogging outline:...
for an XML structure like <outline text="Blogging" title="Blogging"><.../>
. I want to extract the title and text, and clearly, {{ .text }}
does not work: that fetches the contents of the text child, which isn’t there.
The documentation on this shiny new feature I’m afraid is far from complete. No mention anywhere of attributes at transform.Unmarshal | Hugo.
Thanks!