请稍侯

为blog添加归档页 archives

05 January 2016

##参考 Jekyll archives grouped by date

blog 根目录下创建文件, archives.html , 内容如下:

---
layout: page
permalink: /archives/
---

<h2>Archives</h2>
<ul>
  {% for post in site.posts %}

    {% unless post.next %}
      <h3>{{ post.date | date: '%Y' }}</h3>
    {% else %}
      {% capture year %}{{ post.date | date: '%Y' }}{% endcapture %}
      {% capture nyear %}{{ post.next.date | date: '%Y' }}{% endcapture %}
      {% if year != nyear %}
        <h3>{{ post.date | date: '%Y' }}</h3>
      {% endif %}
    {% endunless %}

    <li>{{ post.date | date:"%b" }} <a href="{{ post.url }}">{{ post.title }}</a></li>
  {% endfor %}
</ul>

之后就可以通过huyongde.github.io/archives来访问 按照年份归档的页面了