params.social issue with Hugo 120?
mabster opened this issue · comments
Hi gang,
I just updated to Hugo v0.120.1, and now I'm getting build errors with my existing configuration and the Coder theme.
The error is around Twitter cards:
ERROR render of "page" failed: "C:\Users\mabst\source\repos\mabster\themes\hugo-coder\layouts\_default\baseof.html:6:5": execute of template failed: template: posts/single.html:6:5: executing "posts/single.html" at <partial "head.html" .>: error calling partial: "C:\Users\mabst\source\repos\mabster\themes\hugo-coder\layouts\partials\head.html:1:3": execute of template failed: template: partials/head.html:1:3: executing "partials/head.html" at <partial "head/meta-tags.html" .>: error calling partial: execute of template failed: template: _internal/twitter_cards.html:25:9: executing "_internal/twitter_cards.html" at <site>: can't evaluate field twitter in type []interface {}
The Hugo documentation says that for Twitter cards to work, you should set params.social.twitter to your Twitter handle in the config. For example:
[params]
social.twitter = 'mabster'
However, Coder has an array of config values called params.social:
[[params.social]]
name = 'GitHub'
icon = 'fa fa-2x fa-github'
weight = 3
url = 'https://github.com/mabster'
[[params.social]]
name = 'Twitter'
icon = 'fa fa-2x fa-twitter'
weight = 3
url = 'https://twitter.com/mabster'
... etc etc
So Hugo is choking.
Is there an easy fix for this? Or something in the pipeline for v120 support in this theme? Or am I just flat out doing something dumb?
Cheers,
Matt
I can fix it by renaming all the [[params.social]]
elements to [[params.socials]]
(plural) and then changing the first line of layouts\partials\home\socials.html to {{ with .Site.Params.socials }}
. I'm gonna work that way until I hear otherwise.
Note Hugo 120 wants the setting to be "params.author.name" not just "params.author" so I also had to adjust author.html to reflect that!
Thank you for this! Kinda a dumb thing to break lol.
Looks like Hugo 120.2 fixed the "author.name" regression, so if you just have author = "Matt"
in your config file it will build now. So that's something that doesn't need to be changed in the Coder theme.
I ran into this too, @mabster can you put in a PR to fix it here? 😆
@gaborbernat Try Hugo v0.120.3 first! They just released it and I think it fixes this issue. I will test it with my own site this weekend.
Indeed, all good now. Thanks!
OK closing this one because 120.3 seems to have fixed all these issues.