Difference between server and build

Any idea why my content file is published when using hugo server -F but not when using hugo ?

http://localhost:1313/poems/erosphere/chaussettes-a-fleurs/
-> ok the page exists

/public/poems/erosphere/chaussettes-a-fleurs/
-> not existing

https://inwardmovement.github.io/poems/erosphere/chaussettes-a-fleurs/
-> page not found

Kind of solved: I removed a day from the date field and the content is published.
Time here is 2020-10-19 00:50, and I had put date: 2020-10-19 (the date when I create the file, so “today”, as usual).
hugo server -F outputs the file but hugo server does not. So I guess the date is considered to be “a date in the future”, why so? Is it a bug?

This sounds like a time zone issue. Try using a full timestamp with time zone offset and see if you still get the same issue. (2020-10-18T16:17:34-07:00)

If it is 2020-10-19 12:00 here, date: 2020-10-19T11:00:00 does not publish the content but date: 2020-10-19T11:00:00+01:00 does.

Shouldn’t Hugo base its date on the environment/OS date instead of T...+/-00:00 ?
It is an overhead (not technically but conceptually) to add a T...+/-XX:XX to each file, and even more so when working with CMS/content editors.

If you are in Paris, France on 19 October 2020 at noon, the fully qualified time is:

2020-10-19T12:00:00+02:00

This is the same moment in time as:

2020-10-19T11:00:00+01:00

If you want accurate datetime calculations, you need to include time and offset.

Regarding using the env/os date: I’m not sure that makes it any easier conceptually. The server that runs your Hugo build may be in a time zone different to yours or your audience’s. For example, I edit my site in the US, it’s built and hosted on a machine in Germany, and part of the intended audience is in Spain. The date will tick over at different moments in those three places (maybe Germany and Spain are in the same time zone). IMO, it’s best to specify an unambiguous timestamp for publication, because it’s unclear to me which of those three options is the best default interpretation of the zoneless time.

You can use UTC if you prefer. That’s 2020-10-19T20:30:00Z. I’ve also noticed that the date with no time (2020-10-19) is enough to render a date in a Hugo template, but I don’t know how that would behave when filtering “future” posts.

Ok I agree, it’s better to be specific.
I’ll miss the minimalistic yyyy-mm-dd format but I’ll have to get used to yyyy-mm-ddThh:mm±hh:mm, it’s for a good cause. Life’s harsh sometimes :stuck_out_tongue_closed_eyes:

The problem for me is that when I create a content file between 00:00 and 01:00 (or 02:00 if Daylight Saving Time) with date: yyyy-mm-dd (being the date corresponding to “today”, the date of creation of the file), then the page is not published, I guess because the date is considered to be in the future, because (again I guess) a date with no time is interpreted as UTC (+00:00 or Z), but my OS is UTC+01:00 (or UTC+02:00 if DST). When I specify the timezone with date: yyyy-mm-ddThh:mm+01/02:00 then the page is published.

Technically I have this VSCode snippet that takes care of this now (I don’t use archetypes as I find them less practical/quick to use than a simple VSC snippet):

(...)
"body": [
      "---",
      "title: \"$1\"",
      "date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE${CURRENT_HOUR/(.*)/T$1/}:$CURRENT_MINUTE:$CURRENT_SECOND+02:00",
      "---",
      "",
      "$0",
      "",
    ],
(...)

As a side note, if you use Netlify for deploy, just add this (if you are in Zurich TZ) to your netlify.toml, so it will be more consistent.

[context.production.environment]
TZ = "Europe/Zurich"

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