How I filter posts in my Jekyll blog
Some time ago I decided to write a part of my blog in english. There already were a few articles written in russian, thus I needed to apply some filtering mechanism to separate they into different pages.
At first, I moved my old posts index page template into
_includes directory and created two different layouts for both languages with simple content:
Next, I added
lang variable with corresponding value to the front matter of every post and used it in my partial template. Since my Jekyll theme uses non-trivial grouping of posts, it’s impossible to use
if statement, but Jekyll supports filtering and assigning to a new variable:
filtered contains only required posts.