Dealing with future posts in Jekyll
While drafting blog posts in Jekyll, you may want to keep some posts hidden from the public eye until they’re ready to be published. In the world of blogging with Jekyll, there are several effective methods to draft such posts without immediately publishing them. Here are three practical approaches.
Posts with future dates
You can date your blog posts in the future. To preview these posts without making them live, use:
jekyll server --future
Ensure your _config.yml
file includes the setting future: false
to keep future-dated posts hidden on the live blog.
In my previous post, you can find further custom options for running and testing your Jekyll site locally.
Publication settings
When creating a post, you can set its publication status in the metadata:
To mark a post as unpublished:
published: false
To publish a post:
published: true
Using published: false
ensures the post doesn’t appear on your generated site. To preview your blog with unpublished posts, use the command:
jekyll server --unpublished
Using the drafts folder
Drafts are posts you’re still working on. Store them in the _drafts
folder of your Jekyll directory:
- _drafts/
- my-draft-post.md
To view these drafts locally, use:
jekyll server --drafts
Ensure that show_drafts: false
is set in your _config.yml
file to hide draft posts on the live blog. To publish a draft, simply move it from _drafts
to _posts
.
Conclusion
I frequently use the future posts and the drafts folder methods. They’re both effective and straightforward. The publication settings method is also useful, especially when you want to keep a post hidden until it’s ready to be published. Feel free to share more tips in the comments below.
comments