Hugo v0.78.2 regression : executing "" at <.Count>: can't evaluate field Count in type string

Hello, I use Hugo with the beautifulhugo theme. Since the v.0.78.2 (maybe earlier) I have the following error :

Failed to get translated string for language "en" and ID "postedOnDate": template: :1:13: executing "" at <.Count>: can't evaluate field Count in type string

Hugo fails at displaying the date specified in the YAML part of each post as such:

date: 2020-11-13

The conversion seems to be happening in the file /themes/beautifulhugo/i18n/en.yaml :

- id: postedOnDate
  translation: "Posted on {{ .Count }}"

It is working fine with hugo v 0.69.2. I fail to understand the error mentioned above as I have very poor knowledge of both HTML and Go. Any help will be very much appreciated :slight_smile:

Vincent

SOLUTION
Replace {{ .Count }} by {{ . }}. The problem seems to originate from go-i18n, see here: https://github.com/gohugoio/hugo/issues/7822

Thank you @pointyfar

You need to look into the code where you call {{ i18n "postedOnDate" . }} - It looks like there Hugo can’t see a .Count. By the way: Posted on count? Doesn’t sound right. Are you sure you don’t want .Date?

1 Like

Please see these GitHub issues:

1 Like

Thank you for your answer pkollitsch. "postedOnDate" is called here:

<span class="post-meta">
  {{ $lastmodstr := default (i18n "dateFormat") .Site.Params.dateformat | .Lastmod.Format }}
  {{ $datestr := default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format }}
  <i class="fas fa-calendar"></i>&nbsp;{{ $datestr | i18n "postedOnDate"}}
  {{ if ne $datestr $lastmodstr }}
    &nbsp;{{ $lastmodstr | i18n "lastModified"  }}
  {{ end }}
[...]
</span>

Now datestr is here :

*<div class="page-meta">
  {{ $lastmodstr := default (i18n "dateFormat") .Site.Params.dateformat | .Lastmod.Format }}
  {{ $datestr := default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format }}
  {{ if ne $datestr $lastmodstr }}
    {{ $lastmodstr | i18n "lastModified"  }}
  {{ end }}
</div>

So i guess the problem comes from i18n "dateFormat". I am going to investigate this. I completely agree with you, .Count does not feel right. But I am scared to change it and break everything, I lack time to properly do this.

I just saw you answer @pointyfar, thank you very much!

The problem is solved, I edited the first post. Thank you very much. I actually searched in hugo issues, but I was not able to retrieve that one, I apologize.

1 Like