HUGO

buildFuture but hide post

I’m running a blog here, and have an ‘all posts’ page where I’m using the following code

{{ range (where .Site.Pages "Params.series" "post").Reverse }}
                <h1><a href="{{ .Permalink }}/index.html">{{ .Title }}</a></h1>
                <p>{{ .Description }}</p>
{{ end }}

to generate a list of posts.
If I use hugo with buildFuture enabled, any posts with a future date will be published, and I can access them even before the publishDate.
Is there any way I can hide the posts from the list until the publishDate? This would greatly simplify my deployment - I’d only have to push once and not have to worry about remembering to push to GitHub on a specific date.

You can add an additional where to filter the dates:

{{ range where (where ...) ".Date" "le" now }}

Note though that future posts published (future relative to build date) will still be excluded from the list even after that date has passed, unless a new build is generated.

1 Like

Thanks, that’s a great way to do it!