inejwstine
inejwstine

Reputation: 748

Hugo: don't publish future posts

I have a site that I am building with hugo and deploying on Netlify with the standard hugo command. I have a post with the following frontmatter:

---
weight: 99
title: foobar
date: 2022-5-12T1:00:00-07:00
---

Even though date is in the future (as of this writing) the post is being built along with the rest of the site and is visible.

According to this post it shouldn't be visible because date is in the future. I haven't done any date configuration in my config.toml file, but just to check, I tried changing date to publishDate:

---
weight: 99
title: foobar
publishDate: 2022-5-12T1:00:00-07:00
---

I even tried including both date and publishDate, but nothing I've tried so far has had the desired effect. The post still shows up even though the date is in the future.

Again, on Netlify the site is being build with the hugo command, so the --buildFuture option is not included. This is also an issue when I view my site locally with the hugo server command. Is there anything else I should check for or something I'm doing wrong?

Upvotes: 1

Views: 649

Answers (1)

inejwstine
inejwstine

Reputation: 748

I found the problem. Turns out the date format is pickier than I thought. 2022-5-12T1:00:00-07:00 wasn't being recognized as a valid date, so it defaulted to January 1, 0001. Once I changed the date to 2022-05-12T1:00:00-07:00 (making the month two digits instead of one) it recognized the correct date and worked as expected.

Upvotes: 1

Related Questions