Skip to content

Homepage news list shows every article one day early for viewers west of UTC #80

Description

@sanity

Noticed while adding the "Services Without Servers" talk in #79. Not caused by that PR, this is pre-existing and affects every item in the list.

Problem

On the homepage, the News list renders each article's date one day early for anyone in a timezone behind UTC. Checked against the live site just now with the browser timezone set to America/Chicago:

Live homepage shows Article front matter
March 27, 2026 2026-03-28
February 5, 2026 2026-02-06
December 24, 2025 2025-12-25
April 9, 2025 2025-04-10

Every one is off by a day. /about/news/ and /about/video-talks/ are correct, so it is only the homepage.

Cause

latest-news.html takes two paths. The plain path formats server-side and is fine:

{{ .Date.Format "January 2, 2006" }}

The include-releases="true" path (which the homepage uses, so it can merge in the latest GitHub release) hands dates to the browser instead:

(dict "date" (.Date.Format "2006-01-02T15:04:05Z") ...)
return date.toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" });

Article front matter carries a date with no time, so Hugo emits midnight UTC. toLocaleDateString then converts that instant into the viewer's zone, and midnight UTC is the previous evening anywhere west of UTC:

$ TZ=America/Chicago node -e "console.log(new Date('2026-07-24T00:00:00Z').toLocaleDateString('en-US',{year:'numeric',month:'long',day:'numeric'}))"
July 23, 2026

GitHub release entries are unaffected because published_at carries a real time of day.

Suggested fix

Format the article dates server-side, where Hugo already knows the intended calendar date, and only fall back to the JS formatter for release entries that genuinely need timezone conversion. Roughly: add a dateDisplay field to the JSON built in latest-news.html using .Date.Format "January 2, 2006", then in renderNews use item.dateDisplay when present and formatDate(item.date) otherwise.

Sorting can keep using the raw timestamp, so ordering is unaffected.

[AI-assisted - Claude]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions