Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Draft posts in Jekyll

View 2012-06-05-my-example-draft-post.mmd
1 2 3 4 5 6 7 8 9 10
---
title: My example draft post
date: 2012-06-04
slug: 2012/06/04/my-example-draft-post
draft: true
---
 
This post shouldn't show up in overview pages due to its `draft` key being set.
 
(Jekyll doesn't care what extra keys are set, so why not use that feature.)
View 2012-06-05-my-example-draft-post.mmd
1 2 3 4 5 6 7
{% for post in site.posts %}
{% unless post.draft %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
</li>
{% endunless %}
{% endfor %}
byee01 commented

You can just use "published" in the YAML instead.
https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter

Owner
carlo commented

@byee01: But then the actual article isn't rendered at all. My way just hides it from overview/list pages, but you can still visit the page if you know the link.

byee01 commented

That makes sense. Just terminology, I suppose. It's more of a "private" or "hidden" post (publicly viewable, but only if you know the url).

FYI, rendered drafts are going to be included in Jekyll 1.0. You can check them out in the master branch right now.
https://github.com/mojombo/jekyll/pull/769

This is actually a much more flexible and elegant solution. Thanks @carlo.

+1 @carlo thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.