archive - Posts by month in Jekyll -
i trying create archive page of posts website. able have pages each list of posts month in format:
www.mywebsite.com/2016/11 display posts november 2016.
can have page each month have posted dynamically created each time post in new month? don't want have manually create new page each month.
i can group posts year so:
<ul> {% 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="{{ post.url }}">{{ post.title }}</a></li> {% endfor %} </ul>
thanks help.
you can modify date
filter integrate month, e.g. date: "%b %y"
. that's used layout, separate <ul>
each month.
from documentation, month-only values date
filter are:
%b
: abbreviated month name.%b
: full month name.%m
: month of year (01 - 12).
complete loop:
<ul> {% post in site.posts %} {% assign currentdate = post.date | date: "%b %y" %} {% if currentdate != date %} <li id="y{{currentdate}}">{{ currentdate }}</li> {% assign date = currentdate %} {% endif %} <li><a href="{{ post.url }}">{{ post.title }}</a></li> {% endfor %} </ul>
about generating pages, afaik can done through plugin. if can't use plugins, e.g. if you're hosting pages on github, best can reduce pages short yaml frontmatter relying on layout, in this answer.
Comments
Post a Comment