5

i've got a static content site and I actually don't want articles display in reverse chronological order, using jekyll/liquid, what are some creative ways I can accomplish this without having to revert to reverse ordering the dates on all posts ?

John
  • 1,246
  • 15
  • 34
  • Is there are particular order in which you do want them to appear? For instance: alphabetical order by post.name, forward chronological, sorted by category or tags, etc – nicksuch Mar 27 '14 at 21:25
  • 1
    I would be open to experimenting with any of those options, frankly, forward chronological order would be fine, always looking to know more about how to manipulate the behavior. thanks. – John Mar 27 '14 at 23:50

2 Answers2

14

With some ugly looking Liquid, it's possible to sort by something else.

Here's an example how to create a tag page, with alphabetically sorted tags.

In this example, I'm sorting the tags (and then the posts per tag are sorted in reverse chronological order - I didn't change that).
But you could use the same technique to order the posts by title or URL, for example.


EDIT:

If you just want to list your posts in forward chronological order instead of the default reverse chronological order, there's a much, much simpler solution - the reversed keyword:

{% for post in site.posts reversed %}
    <!-- whatever -->
{% endfor %}
Community
  • 1
  • 1
Christian Specht
  • 35,843
  • 15
  • 128
  • 182
1

To list your Posts by Category, you could do the following:

  {% for category in site.categories %}
  <h2>{{ category[0] }}</h2>
  <ul class="posts">
    {% for post in category[1] %}
      <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endfor %}
  </ul>
  {% endfor %}

This would yield something similar to this:

rendered Jekyll site showing category-based navigation

Note that with this method, Posts are still listed in reverse chronological order within each category. You can see this code in action here.

nicksuch
  • 1,544
  • 11
  • 11