How To Publish Jekyll Drafts

Having recently moved my blog to Jekyll and hosted it on Aerobatic, I needed the ability to publish draft posts to share with others before being visible on my main index.html page.

I played around with the _drafts option but that wasn’t exactly what I was looking for, so here’s what I eventually did.

In my draft post markdown file, I created a draft tag:

--- title: some title subtitle: some subtitle layout: post date: 2015-07-25 description: some description. tags: - draft ---

Next, in my index page that lists all of my posts, I added an unless statement to qualify which posts are actually listed.

{% for post in paginator.posts %} {% unless post.tags contains 'draft' %}

{{ post.title }}

{{ post.description }}


{% endunless %} {% endfor %}

And that’s it! Hope this helps.

comments powered by Disqus