# When using :git for lastmod, pages are tagged with a timestamp of Jan 01, 0001

**URL:** <https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614>\
**Category:** support\
**Tags:** dateformats, git, gitinfo\
**Created:** [December 28, 2023, 2:34am UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614 "2023-12-28T02:34:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdzero](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fdzero](https://discourse.gohugo.io/u/fdzero)\
**Post date:** [December 28, 2023, 2:34am UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614/1 "2023-12-28T02:34:20Z")

</div>

I was able to overcome my last issue that I posted about with success, got everything working, then realized that my categories for blogs, were showing a date stamp of “Jan 01, 0001” even though none of the other posts or content would show last mod.

I am using the:

> **[Stack](https://themes.gohugo.io/themes/hugo-theme-stack/)**
>
> Hugo Theme Stack Card-style Hugo theme designed for bloggers.
> Quickstart Use this template: CaiJimmy/hugo-theme-stack-starter
> Demo Starter template demo: demo.stack.jimmycai.com Dev build: dev.stack.jimmycai.com Documentation Visit...

And in particular it only appears on this page (using the demo theme for context):

> **[Categories](https://demo.stack.jimmycai.com/categories)**
>
> Lorem ipsum dolor sit amet, consectetur adipiscing elit.

However, I can’t narrow down the cause. I do know it is git, as if I add `":git",` to lastmod between `lastmod` and `date` here:

```auto
enableGitInfo = true
[FrontMatter]
date = ["date", "publishDate", "lastmod"]
lastmod = ["lastmod", "date", "publishDate"]
publishDate = ["publishDate", "date"]
expiryDate = ["expiryDate"]

```

So:

```auto
lastmod = ["lastmod", ":git", "date", "publishDate"]

```

That is when all of the issues start to happen.

I narrowed the codebase down to [this section](https://github.com/CaiJimmy/hugo-theme-stack/blob/master/layouts/partials/article/components/footer.html), which uses the lastmod frontmatter date in the blog post:

```auto

    {{- if ne .Lastmod .Date -}}
    <section class="article-lastmod">
        {{ partial "helper/icon" "clock" }}
        <span>
            {{ T "article.lastUpdatedOn" }} {{ .Lastmod.Format ( or .Site.Params.dateFormat.lastUpdated "Jan 02, 2006 15:04 MST" ) }}
        </span>
    </section>
    <section class="article-lastmod">
        {{ partial "helper/icon" "hash" }}
        <span>
            {{ if .IsPage }}<em>{{ with .GitInfo }}| {{ .Subject }} | {{ .AbbreviatedHash }}{{end }}</em>{{ end }}
        </span>
    </section>

```

But that section is for a completely different page.

The demo link I gave above, for categories, I believe is using this file:

> <https://github.com/CaiJimmy/hugo-theme-stack/blob/master/layouts/partials/article-list/compact.html>

But I don’t fully understand how git is interfering here:

```auto
            <footer class="article-time">
                <time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'>
                    {{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}
                </time>
            </footer>

```

When Git is enabled, it doesn’t matter if lastmod in the frontmatter of a blog post is set to any of the following:

```auto
date = "2017-06-23"
lastmod = "2019-05-30"
lastmod = 
lastmod = ""

```

The category page will still show January 01, 0001.

The versions of the software I am running are:

```auto
$ git version                                                                                                                                                                             
git version 2.39.3 (Apple Git-145)
 
$ go version                                                                                                                                                                             
go version go1.21.5 darwin/arm64
 
$ hugo version                                                                                                                                                                            
hugo v0.121.1-00b46fed8e47f7bb0a85d7cfc2d9f1356379b740+extended darwin/arm64 BuildDate=2023-12-08T08:47:45Z VendorInfo=brew

```

I did read this:

> <https://github.com/gohugoio/hugo/issues/9810>
>
> GitInfo doesn't seem to be set when a page has exactly 1 commit. I have a partia…l with this (simplified) code:
> 
> {{- $recent := where .Site.RegularPages.ByLastmod.Reverse "Type" "eq" "notes" }}
> {{- $recent\_num := (.Site.Params.widgets.recent\_num | default 10) }}
> 
> {{- if $recent }}
> \<ul\>
> {{- range first $recent\_num $recent }}
> {{- if ne .Title "" }}
> {{ .GitInfo }}
> {{ $lastmod := .Lastmod.Format "Jan 2, 2006" }}
> \<li\>\<a href="{{ .RelPermalink }}"\>{{ .Title }}\</a\>\<br /\> \<span class="meta"\>{{ $lastmod }}\</span\>\</li\>
> {{- end }}
> {{- end }}
> \</ul\>
> {{- end }}
> 
> Which prints this:
> 
> !\[Screen Shot 2022-04-21 at 19 23 18\](https://user-images.githubusercontent.com/69429/164516391-56d89d0b-2696-49b3-8bc2-481cd809e9e3.png)
> 
> The file has exactly 1 commit:
> 
> !\[Screen Shot 2022-04-21 at 19 24 04\](https://user-images.githubusercontent.com/69429/164516597-41d698fe-598f-46cf-a32f-7d8499cac19f.png)
> 
> All the other files have more than 1 commit. From Hugo's Lastmod and GitInfo doc pages I expect that pages with exactly 1 commit have GitInfo populated like pages with more than 1 commit.
> 
> My config.toml \[frontmatter\] config looks like this:
> 
> \`\[frontmatter\]
> date = \["date", "publishDate", "lastmod"\]
> lastmod = \["lastmod", ":git", "date", "publishDate"\]
> publishDate = \["publishDate", "date"\]\`
> 
> \### What version of Hugo are you using (\`hugo version\`)?
> 
> hugo v0.97.3-078053a43d746a26aa3d48cf1ec7122ae78a9bb4 darwin/amd64 BuildDate=2022-04-18T17:22:19Z VendorInfo=gohugoio
> 
> \### Does this issue reproduce with the latest release?
> 
> Yes

> [@Incorrect .Lastmod (:git) date when deploying using Github Pages](https://discourse.gohugo.io/t/incorrect-lastmod-git-date-when-deploying-using-github-pages/40900):
>
> 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](https://github.com/plundration/plundration.github.io/) Dates on my …

If I set `core.quotepath` to false, the issue still persists.

An example can be found here:

> **[GitHub - delize/example-blog-issue](https://github.com/delize/example-blog-issue)**
>
> Contribute to delize/example-blog-issue development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![antoinentl](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/antoinentl/32/12914_2.png) [@antoinentl](https://discourse.gohugo.io/u/antoinentl)\
**Post date:** [December 28, 2023, 2:53pm UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614/2 "2023-12-28T14:53:16Z")

</div>

Two things:

- I’m not sure the problem is linked to `GitInfo`, because the `exampleSite` from the theme “hugo-theme-stack” don’t use it;
- you have created an index page for all of your categories, and it’s not that the theme did initially. I try to put a date on the file `content/blog/categories/Google-Workspace/_index.md`, and it works. If I delete the file `content/blog/categories/Google-Workspace/_index.md` and it does exactly what you want. So you have to fix the way the date is called on the categories page.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [December 28, 2023, 6:27pm UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614/3 "2023-12-28T18:27:16Z")

</div>

Always use lowercase paths for content/your-taxonomy/your-term/\_index.md.

---

<div class="post-metadata">

**Author:** ![fdzero](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fdzero](https://discourse.gohugo.io/u/fdzero)\
**Post date:** [December 28, 2023, 10:58pm UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614/4 "2023-12-28T22:58:22Z")

</div>

> [@antoinentl](#):
>
> you have created an index page for all of your categories, and it’s not that the theme did initially. I try to put a date on the file `content/blog/categories/Google-Workspace/_index.md`, and it works. If I delete the file `content/blog/categories/Google-Workspace/_index.md` and it does exactly what you want. So you have to fix the way the date is called on the categories page.

Both the example site and their starter template site have an “Example” (in one case called “Test”) where they have an initially created category that does what I am trying to achieve (without GitInfo):

> <https://github.com/CaiJimmy/hugo-theme-stack/blob/master/exampleSite/content/categories/Test/_index.md>

> <https://github.com/CaiJimmy/hugo-theme-stack-starter/blob/master/content/categories/example-category/_index.md>

> **[Category: Test - Example Site](https://hugo-theme-stack.netlify.app/categories/test/)**
>
> This is an example category

> **[Category: Example Category - Hugo Theme Stack Starter](https://demo.stack.jimmycai.com/categories/example-category/)**
>
> A description of this category

Both of these are categories that are manually created and either contain an image or at least a descriptive category that is not generated from the content. But as you have noticed, neither contain dates.

But that is where I am having difficulty understanding what is going on.

The date here:

> <https://github.com/CaiJimmy/hugo-theme-stack/blob/master/layouts/partials/article-list/compact.html>

Is just calling `.Date`  
`{{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}`

Which should use the `date` frontmatter from the original post?

In any case, I have modified the footer.html file:

```auto
    {{- if gt .GitInfo.CommitDate .Lastmod -}}
    <section class="article-lastmod">
        {{ partial "helper/icon" "clock" }}
        <span>
            {{ T "article.lastUpdatedOn" }} 
            {{ with .GitInfo.CommitDate }}
                {{ . | UTC.dateFormat "January 02, 2006 15:04 MST" }}
            {{ end }}   
            <!-- {{ .GitInfo.CommitDate.Format "January 02, 2006 15:04 MST" }} -->
        </span>
    </section>
    {{- else if .Lastmod -}}
    <section class="article-lastmod">
        {{ partial "helper/icon" "clock" }}
        <span>
            {{ T "article.lastUpdatedOn" }} {{ .Lastmod.Format ( or .Site.Params.dateFormat.lastUpdated.UTC.Format "January 02, 2006 15:04 MST" ) }}
        </span>
    </section>
    {{- else if ne .GitInfo.CommitDate .Date -}}
    <section class="article-lastmod">
        {{ partial "helper/icon" "clock" }}
        <span>
            {{ T "article.lastUpdatedOn" }} {{ .GitInfo.CommitDate.UTC.Format "January 02, 2006 15:04 MST" }}
        </span>
    </section>

```

This seems to be working correctly now. However, I have noticed a different issue, which primarily appears on Cloudflare Pages.

[https://community.cloudflare.com/t/re-timezone-format-issue/391130/7](https://community.cloudflare.com/t/re-timezone-format-issue/391130/7)

I have tried setting timezones locally in the environment variables using:

```auto
TZ
/usr/share/zoneinfo/Etc/UTC

```

However that doesn’t sem to have worked.

---

<div class="post-metadata">

**Author:** ![fdzero](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fdzero](https://discourse.gohugo.io/u/fdzero)\
**Post date:** [December 28, 2023, 10:59pm UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614/5 "2023-12-28T22:59:42Z")

</div>

> [@jmooring](#):
>
> Always use lowercase paths for content/your-taxonomy/your-term/\_index.md.

This has been fixed in my private version of the repo.

---

<div class="post-metadata">

**Author:** ![krischik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/krischik/32/20246_2.png) [@krischik](https://discourse.gohugo.io/u/krischik)\
**Post date:** [January 1, 2024, 9:28am UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614/6 "2024-01-01T09:28:31Z")

</div>

I find the requirement to use lowercase quite annoying. Especially since most terms are proper names which should be capitalised. And in German we capitalise all nouns. Not being able to use upper case characters at many places in Hugo is very restrictive.

This is a documentation tool. Don’t restrict the Authors in there artistic freedom to us upper case characters.

---

<div class="post-metadata">

**Author:** ![chrillek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/chrillek/32/19797_2.png) [@chrillek](https://discourse.gohugo.io/u/chrillek)\
**Post date:** [January 1, 2024, 9:58am UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614/7 "2024-01-01T09:58:39Z")

</div>

You can use uppercase nearly everywhere you want (and I do, being German). The one notable exception are the _paths_ to taxonomies and terms. I don’t see why that is a serious restriction.  
And why is Hugo a documentation tool more than a blog tool or whatever?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [January 1, 2024, 8:08pm UTC](https://discourse.gohugo.io/t/when-using-git-for-lastmod-pages-are-tagged-with-a-timestamp-of-jan-01-0001/47614/8 "2024-01-01T20:08:26Z")

</div>

To clarify…

The scope of unexpected behavior described by the OP is very narrow.

#### Conditions

1. The **term** page does not have a **date** field in front matter, AND
2. The path to the **term** page is not lowercase, AND
3. The `enableGitInfo` parameter in site configuration is set to `true`

There’s another condition that I haven’t nailed down yet, perhaps intermittent.

#### Expected behavior

The **term** page’s rendered `.Date` should be the most recent **date** of the content to which the term is assigned.

#### Actual behavior

The **term** page’s rendered `.Date` is the zero date.

#### Minimal reproducible example

```plaintext
git clone --single-branch -b hugo-forum-topic-47614 https://github.com/jmooring/hugo-testing hugo-forum-topic-47614
cd hugo-forum-topic-47614
hugo server

```

* * *

**Other than the narrowly defined behavior described above, I am not aware of any problems associated with uppercase or mixed case term page paths.**
