Create a gist now

Instantly share code, notes, and snippets.

Embed
Draft posts in Jekyll
---
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.)
{% for post in site.posts %}
{% unless post.draft %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
</li>
{% endunless %}
{% endfor %}
@byee01

This comment has been minimized.

Show comment
Hide comment
@byee01

byee01 Jul 25, 2012

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

byee01 commented Jul 25, 2012

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

@carlo

This comment has been minimized.

Show comment
Hide comment
@carlo

carlo Jul 25, 2012

@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.

Owner

carlo commented Jul 25, 2012

@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

This comment has been minimized.

Show comment
Hide comment
@byee01

byee01 Jul 25, 2012

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).

byee01 commented Jul 25, 2012

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).

@robwierzbowski

This comment has been minimized.

Show comment
Hide comment
@robwierzbowski

robwierzbowski Apr 13, 2013

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

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

@olivierlacan

This comment has been minimized.

Show comment
Hide comment
@olivierlacan

olivierlacan Jun 7, 2013

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

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

@davidnormo

This comment has been minimized.

Show comment
Hide comment
@davidnormo

davidnormo Dec 14, 2014

+1 @carlo thanks!

+1 @carlo thanks!

@ahmadajmi

This comment has been minimized.

Show comment
Hide comment
@ahmadajmi

ahmadajmi Apr 19, 2016

Thanks @carlo

Thanks @carlo

@suminb

This comment has been minimized.

Show comment
Hide comment
@suminb

suminb Oct 10, 2016

This is what I was looking for. Thanks.

suminb commented Oct 10, 2016

This is what I was looking for. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment