Error: can't evaluate field name in type interface {}

Hi,

I get the error can't evaluate field name in type interface {}

Here the markdown:

        photographer:
          id: '581998'
          itemType: photographer
          updatedAt: '2018-12-13T10:03:54.000Z'
          createdAt: '2018-12-13T10:03:54.000Z'
          url: ''
          name: My name

And the template code: {{ .Params.photographer.name }}

When I range .Params.photographer and print the values everything is available.

Hugo Version: 0.52
CMS: DatoCMS

Error output: Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: post/single.html:39:23: executing "main" at <partial "widgets/cre...>: error calling partial: "/home/my/domain/layouts/partials/widgets/credits.html:10:28": execute of template failed: template: partials/widgets/credits.html:10:28: executing "partials/widgets/credits.html" at <.Params.photographer...>: can't evaluate field name in type interface {}

I guess you have pages without that param. Try

{{ with .Params.photographer }}{{ .name }}{{ end }}
3 Likes

@bep Thank you very much! <3

1 Like