Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 1.13 KB

2018-11-26-skipping-posts-in-jekyll-feed.md

File metadata and controls

30 lines (20 loc) · 1.13 KB
tags
jekyll

Problem:

I needed a place to host simple pages when necessary for my personal apps. Like a privacy policy for my app. I don't want to show it as a part of my blog (for obvious reasons).

Solution:

What I essentially need is a filter on all my posts to be shown.

new_posts = filter(posts)

Since, Jekyll uses liquid templating engine, we can rely on that for our filter.

Jekyll allows you to add meta data to posts using front matter. So I added a tag to posts I didn't want to show as DO_NOT_SHOW_IN_POSTS. Also, I filtered out these posts in index.html, and voila, the blog no more shows a link to these posts. They are accessible only if you have link to them.

{% highlight HTML linenos %} {% raw %}

{% if post.tags contains 'DO_NOT_SHOW_IN_POSTS' %} {% else %} {% endif %}

{% endraw %} {% endhighlight %}

You can check this post to see how the tag is added to the post.