Incorrect .Lastmod (:git) date when deploying using Github Pages

Hello, I am having a problem with using .Lastmod.

I expect it to return the date given by ":git" so .GitInfo.AuthorDate, (because I have it set in config.toml) which is exactly what it does when I use hugo server or run the command hugo --minify --cleanDestinationDir --gc dirrectly and host it as a live-server.

However when I build it and deploy it to Github Pages using Github Actions, it instead shows some other date (for some it is the current day and others 01 Jan 01.

My repo

Dates on my site: link
Dates using hugo server:
image

Relevant job in workflow:

jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: 'latest'
          extended: true

      - name: Build
        run: hugo --minify --cleanDestinationDir --gc

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public
          publish_branch: master  # deploying branch
          cname: plundration.github.io/

Code for getting the date:

{{.Lastmod.Format "02 Jan 06"}}

Lastmod config:

...

enableGitInfo = true
[frontmatter]
    lastmod = [":git"]

...

Versions:

hugo v0.104.2+extended linux/amd64 BuildDate=unknown
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.19.1"

git version 2.37.3

I think you’re running into this issue:
https://github.com/gohugoio/hugo/issues/9810

In your local git configuration, what is the value of core.quotepath?

It is set to false

So you need to do the same with your GH deployment.

https://github.com/gohugoio/hugo/issues/9810#issuecomment-1107519804

I’m not able to find the correct syntax for the workflow…
Also can’t find it in the workflow in the github pages repo mentioned in the issue.

EDIT: im asssuming that git config isn’t shared with remote

Here’s the GH workflow from the example repo:
https://github.com/jmooring/hugo-stork/blob/main/.github/workflows/gh-pages.yml#L26-L27

And here are the relevant lines from the build script:
https://github.com/jmooring/hugo-stork/blob/main/build.sh#L27-L32

You can just add this directly to your workflow as an additional step:

git config --global core.quotepath false
1 Like

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