My Top 10 Liquid Recipes

Hello fellow Jekyllers!

I’ve taken a minute to jot down 10 Liquid tricks that I’ve learned over the last few years of writing the Open Buddhist University:

Please take a minute to review. I’d love to hear if any are new to you and if there are any cool tricks of your own that I’ve forgotten!



Amazing! Quite a number of tricks I didn’t know yet. Thank you!

1 Like

Your “Recurse in an include” is a great idea for nested lists! Thanks!

1 Like

You’re welcome! I actually do use a recursive include to build my nested tags directory. Each tag has a parent in the frontmatter, and the recursive include crawls it like a tree :smiling_imp:

Hello, I believe I have seen this before, but haven’t commented on / left a feedback at the time. Glad I got another opportunity.

Overall, it is a good collection of snippets but I really fail to understand the magic / logic in Make a map.
{{ mykeys[2] }} => {{ myvalues[2] }} ??? Sure, this code would render into new_key => new_value, but how is that in any way part of a new data structure my_map that would allow one to subsequently use my_map["new_key"] to get new_value rendered?

On the same note, its sad that variables defined in an include “leaks” into outer scope. Though not exactly your fault, but now we cannot have this “leak” fixed to maintain compatibility.

One other tip (not exactly a recipe) you could popularize is that Whitespace is beautiful and improves readability. What I mean by this is that {% include alpha.html foo="lorem" bar='ipsum' %} is equivalent to the following:

  • {% include alpha.html foo = "lorem" bar = 'ipsum' %}
  • {% include alpha.html
         foo = "lorem"
         bar = 'ipsum' %}
1 Like

The very next section shows how using a simple include :smile: Two, unsorted arrays are not the most efficient implementation of a map, but it is a implementation.

Of course, sorting the arrays by the key would be more efficient, but I’ll leave that one as an exercise to the reader :wink:

Could always fix it in Jekyll 5.0 :wink:

Thanks for the tip!

I still don’t see it. :see_no_evil: Could you post the entire working code here? :smiling_face_with_tear:

{% assign value = nil %}
{% for k in keys %}
  {% if k == key %}
    {% assign value = values[forloop.index0] %}
    {% break %}
  {% endif %}
{% endfor %}