How to adjust Jekyll post order?

There is an example in the official Jekyll documentation how to create a basic post archive page: Displaying an index of posts Bonus: For a prettier archive page (grouped by year or year/month), see this answer. You’re right, I can’t find anything in the docs where it says how the posts are ordered, but in … Read more

Jekyll Filename Without Date

Don’t use posts; posts are things with dates. Sounds like you probably want to use collections instead; you get all the power of Posts; but without the pesky date / naming requirements. https://jekyllrb.com/docs/collections/ I use collections for almost everything that isn’t a post. This is how my own site is configured to use collections for … Read more

Jekyll for loop over all images in a folder?

This worked like a charm for me. No plugins required. My images are in a assets/images/slider directory. {% for image in site.static_files %} {% if image.path contains ‘images/slider’ %} <img src=”https://stackoverflow.com/questions/17677094/{{ site.baseurl }}{{ image.path }}” alt=”image” /> {% endif %} {% endfor %} The image.path contains ‘images/slider’ makes sure that only images in that folder … 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