title: How to group posts by date on home page in Jekyll?
body: <p>In Jekyll, I would like my home page to list the most recent posts grouped by date, like so:</p>
  
  <p>September 6, 2013</p>
  
  <ul>
  <li>Post 1</li>
  <li>Post 2</li>
  <li>Post 3</li>
  </ul>
  
  <p>September 5, 2013</p>
  
  <ul>
  <li>Post 1</li>
  <li>Post 2</li>
  </ul>
  
  <p>Basically, I just want to spit out a date heading when a post in the loop is from a different date from the one previously processed. I've tried to do this by testing if the next post in the for loop matches the date of the last post, and to display a date header only if it doesn't. This is what my Liquid template looks like:</p>
  
  <pre><code>---
  layout: default
  title: Home Page
  ---
  
  {% assign thedate = '' %}
  
  {% for post in site.posts %}
  
      {% if thedate != post.date | date: "%m-%d-%Y" %}
          &lt;h2&gt;{{ post.date | date: "%A, %B %e, %Y" }}&lt;/h2&gt;
      {% endif %}
  
      {% assign thedate = post.date | date: "%m-%d-%Y" %}
  
      &lt;h3 class="headline"&gt;&lt;a href="{{ post.url }}"&gt;{{ post.title }}&lt;/a&gt;&lt;/h3&gt;
      {{ post.content }}
      &lt;hr&gt;
  
  {% endfor %}
  </code></pre>
  
  <p>If instead of using <code>post.date | date: "%m-%d-%Y"</code> I instead say simply <code>post.date</code> it works, and posts are grouped together, but only if the posts have the exact same date and time (not just the same day of the month). That's why I add the more specific <code>post.date | date: "%m-%d-%Y"</code>.</p>
  
  <p>Any ideas? Thanks so much for our help!!</p>