0.35 seems to break something related to GitInfo

Again, thanks a lot for your fantastic work, especially on the recent bundle.

I’m not sure but 0.35 (thru brew) seems to break something (0.34 works just fine)

$ hugo server Building sites … ERROR 2018/02/01 10:10:49 error processing shortcode "shortcodes/derniers_changements.html" for page "changedoc/_index.md": template: shortcodes/derniers_changements.html:15:31: executing "shortcodes/derniers_changements.html" at <sort .Site.Taxonomie...>: error calling sort: can't evaluate a nil pointer of type *gitmap.GitInfo by a struct field or map key name AuthorDate

the guilty line in my shortcode is :
{{ range first $nombre_md (sort .Site.Taxonomies.categories.documentation ".GitInfo.AuthorDate" "desc") }}

I didn’t see anything obvious as a pb.

I reverted (brew) to 0.34 and previous and it compiles fine again.

0.34 process 122 pages.
0.35 process 121 pages (the one with pb).

Any idea if I have some deeper problem or how to diagnose the guilty .md file ??

I would suggest that you use .Lastmod and combine that with --enableGitInfo. This is what you want.

Wow that’s quick !! thanks @bep. I’ll try your tip.

On a related (?) note, there is some change also with the .json files on 0.35.

WARN 2018/02/01 10:48:56 Failed to read data from gitLab-127-issues-1.json/gitLab-127-issues-1.json: json: cannot unmarshal array into Go value of type map[string]interface {}

That is this issue:

We will issue a patch release on Monday.

1 Like

Your tip worked just fine.

But I guess there is some “magic” involved because I already had
enableGitInfo = true in my config.toml

Adding --enableGitInfo as a hugo parameter, made it work.

The magic should be in the .Lastmod– that == the git author date if the git is enabled.

Sorry, I was not clear on my comment.

I mean that the hugo behaviour is different for

  • enableGitInfo = true in my config.toml => does’nt work
  • option --enableGitInfo passed to hugo command line => does work OK

Reading the doc it seems that it should behave the same way.

It should.

So … I have a use case where it doesn’t, if you need it.

I can narrow the problem to

  • enableGitInfo set to true in toml = > {{ if .GitInfo }} is false
  • enableGitInfo parameter passed to hugo = > {{ if .GitInfo }} is true

And there is also a problem on date value because {{.Lastmod.Format "02 Jan 2006"}} returns “01 Jan 0001” when enableGitInfo set to true in toml.

HTH

@bep do you want me to open an issue on github ??

EDIT : issue opened https://github.com/gohugoio/hugo/issues/4369

FWIW, I don’t see that issue, and I enable GitInfo in config.toml. Can you share the site source so that the issue can be reproduced by someone, and the root cause can be found?

  • Here is the link for the full git folder :
  • I put 2 screenshots (command = hugo server) with 0.34 & 0.35 with the (obvious) problem
  • Line of code is : <td>{{.Lastmod.Format "02 Jan 2006"}} - .GitInfo = {{ .GitInfo }}</td>

HTH.

I found the source of the problem.

My config.toml is :

...
[params]
enableRobotsTXT = true
enableGitInfo = true
...

if put the enableGitInfo parameter OUTSIDE [PARAMS], it works fine again.
So I guess the change between 0.34 & 0.35 is the search for this parameter.

...
enableGitInfo = true

[params]
enableRobotsTXT = true
...

It’s odd that that worked before.

That another enable also needs to be before the [params].

TOML – All Hugo config variables need to be before anything [foo].

1 Like

It was a bug fix in Hugo 0.35 that cleaned up a slightly odd mixing of params and config settings per language, creating the hard-to-debug “theme in params” issue.

So, I guess the above worked in Hugo 0.35, but these settings does not belong in the params section.

1 Like