kilian kilian - 11 months ago 76
HTML Question

Jekyll Github pages how to hide a post

I am using jekyll with Github pages for my website.
I am trying to make some posts not visible in the home but they can be linked from another post.
In the frontmatter I tryed to add a field visible like this:

layout: post

And then in the index.html file I did a if check:

<div class="posts">
{% for post in paginator.posts %}
{% if post.visible== 1 %}

<div class="post">
<a href="{{ post.url }}">
{{ post.title }}

<span class="post-date">{{ | date_to_string }}</span>
<a class="subtitle" href="{{ post.url }}">
{{ post.excerpt }}
{% endif %}
{% endfor %}

The idea is that when I set 0 in the visible field, the post won't be visible in the home. Unfortanely this is not working, do you have any hints? Thanks

Answer Source

Try to change your front-matter from visible:1 to visible: 1.

I just tried to reproduce your example on my machine, and I found that Jekyll seems to picky about the blanks in the front-matter.

With visible: 1, your example works for me.

With visible:1, Jekyll outputs the following error message while building the site:

YAML Exception reading C:/foo/ (): could not find expected ':' while scanning a simple key at line 5 column 1

...but it still finishes building and the generated site works, except that the post is not visible.