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:

Relevant job in workflow:

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

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

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

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

Code for getting the date:

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

Lastmod config:


enableGitInfo = true
    lastmod = [":git"]



hugo v0.104.2+extended linux/amd64 BuildDate=unknown

git version 2.37.3

I think you’re running into this issue:

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.

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:

And here are the relevant lines from the build script:

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.