HUGO

Future date

Hi. If I set the date in the front matter to a future date, do I have to do anything else or the post will show up on (or after) that date if I do a build at that (or after that) date?

Hugo in itself does not use an automatic process. Therefore, you must either recreate your page at the appropriate time or create a cronjob that recreates your page, for example, once a day.

1 Like

I am not asking about automation but if the post will show up when I build on or after the date I put in the date field.

@fryboyter’s answer is right. Maybe re-read it.

Automation would mean that your website is deployed every x hours. It isn’t. So NO. Hugo does NOT suddenly show your future post if you compiled your site in the past (in regards to that future post). Hugo does create pages from your content. Your frontmatter defines parameters. If they say “don’t publish if NOW is before the publish date of my post” then it will not create that page. If you DO NOT run hugo again after that it will not create that page magically.

I hope you understand that.

What you CAN do to “publish” the post when the time is right: you could do an “automatic” (there it is again, that term) deploy of your website (run hugo, then upload what is created) every x hours and if the post THEN is in the past of the time when the hugo process runs then it will be shown.

Or…

You run hugo with a CLI parameter that publishes future posts ( --buildFuture), but then they will be live immediately and you need some other mechanism to hide those “future” posts from visitors.

Let me simplify my question coz I think y’all do not understand what I am asking. I set a date in the future e.g. date: 20 Jan 2022. I don’t care about any builds before that date making the post show up. But I would like any build on or after that date to make the post show up. Will that work?

Answer: Yes. If your frontmatter is formatted right.

Just to go 100% sure, a date: frontmatter timestamp should look like this:

2022-01-14T20:42:00+07:00

Your version 20 Jan 2022 might work or fail. Having a 100% true timestamp like the one above will be sure.

Okay! I saw HUGO is hiding these posts by default, so I want to space them out. I do rebuild my site twice weekly (when I have no other stuff to edit or deploy) for my shuffled related posts, so I either way, I am scheduling the dates in between these builds.

I updated my answer… you need to go sure that your timestamp is properly formatted. “January 20th” won’t work.

I have Format defined in my single template date for the date. Unless Hugo doesn’t use that during builds? Either way, I use the format above for aesthetics. As long as the post shows up on that day, then no problem.

Aestetics: In your layouts. Timestamp: in your frontmatter. Do the timestamp thing in the frontmatter of your posts. You can format them via your layout (see the docs below) easily. The frontmatter needs to be “machine-readable”.

I just moved to Hugo with 400+ posts. Can’t just edit all those dates I used into another format. If it helps, I have the timezone set in the configuration file. I am sure that will work.

show a sample of your frontmatter. setting timezone in your frontmatter won’t help with an arbitrarily formatted date string. it might work by luck, but don’t count on it. On the other side, how many future posts can one have with transferring a site from one system to another.