which reads the file correctly and outputs highlighted code. However, how do I pass in the {{ .Params.slug }} from my content to that function, so as to dynamically alter that partial directory path? Something like (but not, I know):
I have no idea why you had that in the first place… I assumed that for some odd reason, you directory name began with ', so I left it there …
One of your files doesn’t have that .Params.slug set… so that’s returning nil… what you are seeing is because nil is trying to get printed using the %s.
Assuming that you have a default partial called components/foo.html, you can do:
Thanks for the catch on the single quote, I didn’t notice it was my typo.
I was perhaps not using slug correctly, so I’ve changed to ‘nickname’ as set in my content’s front-matter. (though yes, I am going to have a unique partial for each slug, I’m using Hugo for a pattern library website and the partials are the patterns I’m referencing to pull in to the page)
I’m able to call
{{ .Params.nickname }}
Just fine earlier in the template, so I’m not sure why it’s not getting that here and returning nil instead?