luizdepra / hugo-coder

A minimalist blog theme for hugo.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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!

Upgrading to v0.120.3 Fixes most of the problems

I found this after doing some testing (thanks @mabster)

author.name = "Jane Doe" is needed over author = "Jane Doe"

But params.social to params.socials appears to have been a bug in v0.120.2 (see issue #11660)

Hope this helps.
-S.A

OK closing this one because 120.3 seems to have fixed all these issues.