Error calling first: can't iterate over maps.Params

All my old sites started to throw errors messages even true I did not make any changes apart from updating the theme. The error message in question is:

hugo server 
Watching for changes in /Users/Shared/Work/Projects/6502Tutorial/Documents/{archetypes,assets,content,data,layouts,static,themes}
Watching for config changes in /Users/Shared/Work/Projects/6502Tutorial/Documents/hugo.toml, /Users/Shared/Work/Projects/6502Tutorial/Documents/themes/congo/config/_default, /Users/Shared/Work/Projects/6502Tutorial/Documents/go.mod
Start building sites … 
hugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/amd64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew

WARN  [CONGO] Theme parameter `author` block in `languages.xx.toml` has been renamed to `params.author`. Please update your site configuration.
ERROR render of "page" failed: "/Users/Shared/Work/Projects/6502Tutorial/Documents/themes/congo/layouts/_default/baseof.html:11:6": execute of template failed: template: _default/single.html:11:6: executing "_default/single.html" at <partial "head.html" .>: error calling partial: execute of template failed: template: _internal/opengraph.html:6:15: executing "_internal/opengraph.html" at <partial "_funcs/get-page-images" .>: error calling partial: execute of template failed: template: partials/_funcs/get-page-images.html:18:21: executing "partials/_funcs/get-page-images.html" at <first 1 .>: error calling first: can't iterate over maps.Params
Built in 148 ms
Error: error building site: render: failed to render pages: render of "page" failed: "/Users/Shared/Work/Projects/6502Tutorial/Documents/themes/congo/layouts/_default/baseof.html:11:6": execute of template failed: template: _default/single.html:11:6: executing "_default/single.html" at <partial "head.html" .>: error calling partial: execute of template failed: template: _internal/opengraph.html:6:15: executing "_internal/opengraph.html" at <partial "_funcs/get-page-images" .>: error calling partial: execute of template failed: template: partials/_funcs/get-page-images.html:18:21: executing "partials/_funcs/get-page-images.html" at <first 1 .>: error calling first: can't iterate over maps.Params
make: *** [run-hugo] Error 1

I guess something changed. But what? Yes, I have seen the warning but I was waiting for the theme to fix that and I don’t know if that has happened yet.

  • I tried commenting out the author block
  • I tried the theme dev branch instead of stable
  • I tried the compost theme instead of congo. That only fixed the warning
  • I found issue 12210 and tried to remove [params.images]

Those did not improve the situation.

Since you always ask: https://git.code.sf.net/p/tutorial-6502/code, branch develop, directory Documents.

@razon

https://github.com/gohugoio/hugo/blob/v0.121.0/tpl/tplimpl/embedded/templates/partials/_funcs/get-page-images.html#L18

site config

[params.images]
modern_format		= 'webp'
class_name			= 'mx-auto my-1 rounded-md'
alignment_end_class_name	= 'float-right'
alignment_start_class_name	= 'float-left'

And this is why I dislike many of our embedded templates.

2 Likes

I tried removing the image block:

# [params.images]
#   modern_format		= 'webp'
#   class_name			= 'mx-auto my-1 rounded-md'
#   alignment_end_class_name	= 'float-right'
#   alignment_start_class_name	= 'float-left'

But that didn’t do the trick. The website should still work without. But the error message didn’t go away.

Let razon respond when he has a moment. That’s why I tagged him.

Ok. Thanks. I’ll wait for the reply.

In the short term:

1) Comment out the entire params.images block in your site configuration.
2) Update the hugomods module

hugo mod get -u ./...

https://hugomods.com/docs/images/#image-partial-parameters

Since v0.8.3 , the params.images was renamed to params.hugomods.images , to get rid of conflicting with some Hugo built-in templates, see Parameter naming is conflict with Hugo built-in opengraph and twitter-card templates · Issue #26 · hugomods/images · GitHub.

2 Likes

Yes that worked. Thanks.

There’s no reason for @razon to chime in here. This was purely a module upgrade issue.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.