GitHub Pages gets wrong gitinfo for a post page?

I’m running Hugo on GitHub Pages w/ the suggested GitHub Actions. However, I’ve just noticed a discrepancy between the behavior of a locally run Hugo and the Hugo run by GitHub actions.

What I first noticed was that the “Last Modified” date for one of my old posts was wrong on GitHub Pages – it was listed as today, not two weeks ago when I actually last changed it. I have enableGitInfo = true so expected that to be taken from the git info for that page, but it wasn’t right. It was correct on a locally running “development” Hugo instance, but not on the “publication” version on GitHub Pages.

So I did some investigation. I added a stanza in layouts/_default/single just to print some of the .GitInfo data at the top of the page, the .Hash, .Subject, .CommitDate, .AuthorDate, .AuthorEmail, and .AuthorName. When run on the local Hugo instance, the gitinfo was printed was that of the commit that last modified the page in question.

When GitHub Actions ran however, what it printed at the top of the page was the latest commit to the blog repository as a whole, even if it had nothing to do with the page I was viewing. (As a most minimal “Noop” repo change, I just added a file with date > static/EPOCH and committed that.)

Has anyone else noticed this? Am I doing something wrong? Will I have to manually add the relevant “LastModified” date to the frontmatter of my posts/pages? (Which I guess is necessary if you have included figures that change or such w/out changing the page source itself.)

Can you share your Github Pages workflie file?

It should be visible here:
https://github.com/WRSomsky/WRSomsky.github.io/blob/main/.github/workflows/hugo.yml
I believe I took it from the suggested actions for Hugo when setting up the action. I just commented out the Dart SASS, as it’s not used for this theme.

Please compare your workflow with the one in our documentation. Your workflow is missing the fetch depth parameter.

https://gohugo.io/hosting-and-deployment/hosting-on-github/#procedure

https://gohugo.io/methods/page/gitinfo/#hosting-considerations

Ah. Yes. That did it.

Looks like I should have read just a bit further down the GitInfo page. My bad. :face_with_open_eyes_and_hand_over_mouth:

Thanks much!

1 Like

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