Hugo - Timezone Display Issues only on Cloudflare Pages

Hello,

I have been deploying a Hugo based website from Github > Cloudflare Pages using the integration. Generally, this is working fantastic and I’m super impressed and happy with this setup.

However, I have noticed that on the page, that timezones are being shown like this when deployed through Cloudflare Pages:
LAST UPDATED ON DECEMBER 28, 2023 17:50 -0600

This however does not happen on local builds when deployed with hugo --configDir ./config/blog -w server:
LAST UPDATED ON DECEMBER 28, 2023 17:50 CST

On a macOS device or when using https://static-web-server.net/ over docker.

I have done some searching and found this to be a fairly common problem:
https://community.cloudflare.com/t/hugo-timezone-format-issue/390678
https://github.com/gohugoio/hugo/issues/9996

So I have tried to use the current workarounds, and also tried manually specifying the same Hugo and Go versions that I have running locally, but I still run into the issue:

I have also tried adding: “/usr/share/zoneinfo/”, but I believe that is not necessary.

My current build command is:
git fetch --unshallow && hugo --config ./config/root/hugo.yaml && hugo --configDir ./config/blog

Would appreciate any assistance :slight_smile:

The code in question can be found here:

    {{- if gt .GitInfo.CommitDate .Lastmod -}}
    <section class="article-lastmod">
        {{ partial "helper/icon" "clock" }}
        <span>
            {{ T "article.lastUpdatedOn" }} 
            {{ with .GitInfo.CommitDate }}
                {{ . | 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.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.Format "January 02, 2006 15:04 MST"  }}
        </span>
    </section>
    {{- else -}}
    {{- end -}}

Have you tried setting the timeZone config option in your Hugo config?

I have.

I have it set in the blog config as:
timeZone = "Etc/UTC"

But just in case, I also set it under the root config, though that shouldn’t make a difference.

I can’t seem to edit my post, but I wanted to be more clear, that I had already attempted that and the issue still persisted, so that unfortunately did not resolve the issue.

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