1
votes

I am currently working on a static blog based on Jekyll and GH-pages. At the top of my post overview site I do have a section where I would like to place some featured blogposts.

I could probably add the value "featured" to the "tags" in the YAML Front Matter of those posts and insert the line:

{% for post in site.tags.featured %}

Nevertheless I am one of those complicated guys who don't like to stick to the first solution that came in mind (although it probably might be the easiest one).

My idea was to add a new variable featured to my YAML Front Matter and label with the values yes or no (same thing here: yes, I do know that true and false would be easier but I like to be able to transfer the solution to another problem) if it is a featured content (and should be shown in this section) or if it is not.

That might be an easy solution for a jekyll expert but I am pretty new to that kind of static site generator and would love to hear your ideas.

1

1 Answers

0
votes

If you assign featured: true or featured: yes, this filter will work :

{% assign featuredPosts = site.posts | where:"featured", true %}

A {% for post in featuredPosts %} will then do the trick.

Note : all the Truthy and Falsy in Liquid are not working in the actual Jekyll.