This may seem like an easy question, but Iāve been fighting it for a couple of days. I have a section labelled āmusicā that basically is a set of blog posts containing mp3 files from performances by our local community band. In the past, it was a simple HTML file, but Iād like to do it properly. I tried adding it to my front matter like:
[[params.music]]
url = "hugo.mp3"
name = āThe Hugo Songā
[[params.music]]
url = "html.mp3"
name = āThe HTML Songā
But I couldnāt parse that. I could put the TOML in a data file, but how can I specify that particular data file dynamically with the single.html template in the music layout folder? Iād have about 100 separate data files + 100 posts. Thatās why Iād like to put it into the frontmatter if possible.
I tried again using YAML instead of TOML since TOML is brokenā¦ My front matter excerpt looks like:
tags: "Community Band"
music: " Community Band"
playlist:
- songs:
- title: "Big Band Signatures"
url: "bigbandsignatures.mp3"
.- title: "Florentiner March"
.url: "florentiner.mp3"
- title: "New Colonial March"
url: "newcolonial.mp3"
In my single.html template, my code should be something like this if I am correct:
{{ range .Params.playlist.songs }}<li>{{.title}}</li>{{end}}
However, when I build, I get errored out on thatā¦ What am I doing wrong?
Iāve handled arrays like this in site before (to generate nested / multileveled menus for bootstrap), but this isnāt working for the page level array.
Whatās the error message that you got? The issue that that pull request fixes is about a TOML array not parsed and turning up empty (without an error message). Perhaps the error message you got can help troubleshoot this issue.
I originally had the data in toml just like the menu structure, but it just rendered blank lines or errored outā¦ Thatās when I swapped over to YAML because it was noted in the past that this was supposed to workā¦
The line number of that error is the {{ rangeā¦ line. Not much about the error. When I print the page params, all the data shows up, so it is read successfullyā¦
Here is the printf of the .Params:
map[string]interface {}{āplaylistā:interface {}{map[interface {}]interface {}{āsongsā:interface {}{map[interface {}]interface {}{ātitleā:āBig Band Signaturesā, āurlā:ābigbandsignatures.mp3ā}, map[interface {}]interface {}{ātitleā:āFlorentiner Marchā, āurlā:āflorentiner.mp3ā}, map[interface {}]interface {}{ātitleā:āNew Colonial Marchā, āurlā:ānewcolonial.mp3ā}, map[interface {}]interface {}{āurlā:āstarsandstripes.mp3ā, ātitleā:āStars and Stripes Foreverā}, map[interface {}]interface {}{ātitleā:āSymphonic Dances from Fiddler on the Roofā, āurlā:āsymphonicdances.mp3ā}, map[interface {}]interface {}{ātitleā:āThe Prayerā, āurlā:ātheprayer.mp3ā}, map[interface {}]interface {}{ātitleā:āThe Saintsā, āurlā:āthesaints.mp3ā}, map[interface {}]interface {}{āurlā:ātiptoe.mp3ā, ātitleā:āTiptoe through the Tubasā}}}}, ācategoriesā:string{āmusicā}, ātagsā:string{āComal Community Bandā}, āmusicā:āComal Community Bandā}
I actually didnāt have the dots in those linesā¦ I had that when I was trying to fake indent on this site until I discovered that the four spaces indented codeā¦