Enabling Liquid templating syntax highlight in webStorm/phpStorm

I’ve found out that Twig have a very similar syntax to Liquid, enabling the Twig plugin will highlight Liquid syntax and will keep the HTML highlight/autocomplete/emmet functionality working as opposed to the “textMate Liquid bundle”. Go to Settings > Editor > File Types find “Twig” on that list and associate Liquid files with it by … Read more

Liquid templates: even/odd items in for loop

I think you’ll want to use the cycle tag for this. For example: {% for post in site.categories.articles %} <article class=”{% cycle ‘odd’, ‘even’ %}”></article> {% endfor %} If you want different HTML markup for each cycle: {% for item in site.posts %} {% capture thecycle %}{% cycle ‘odd’, ‘even’ %}{% endcapture %} {% if … Read more

Jekyll/Liquid Templating: How to group blog posts by year?

It can be done with much, much less Liquid code than in the existing answers: {% for post in site.posts %} {% assign currentdate = post.date | date: “%Y” %} {% if currentdate != date %} <li id=”y{{currentdate}}”>{{ currentdate }}</li> {% assign date = currentdate %} {% endif %} <li><a href=”https://stackoverflow.com/questions/19086284/{{ post.url }}”>{{ post.title }}</a></li> … Read more

Iterate over hashes in liquid templates

When you iterate over a hash using a variable called hash, hash[0] contains the key and hash[1] contains the value on each iteration. {% for link_hash in page.links %} {% for link in link_hash %} <a href=”https://stackoverflow.com/questions/8206869/{{ link[1] }}”>{{ link[0] }}</a> {% endfor %} {% endfor %}

Jekyll display posts by category

Got it! Needed an intermediate posts loop before listing out individual posts <ul> {% for category in site.categories %} <li><a name=”{{ category | first }}”>{{ category | first }}</a> <ul> {% for post in category.last %} <li><a href=”https://stackoverflow.com/questions/20872861/{{ post.url }}”>{{ post.title }}</a></li> {% endfor %} </ul> </li> {% endfor %} </ul>

How can I show just the most recent post on my home page with jekyll?

This can be accomplished through the use of limit: {% for post in site.posts limit:1 %} … Show the post … {% endfor %} You can also use limit and offset together to “feature” your most recent post: <h1>Latest Post</h1> {% for post in site.posts limit:1 %} … Show the first post all big … … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)