Doing changes to the blog archive page (and others)

I have a blog made in Jekyll, I HAVE to make a blog every time I made changes to its layout. Added blog list split by year and month, and better tags layout too

So, at this point you should not be surprised at a blog that talks about making and optimizing the way this blog is done. I already made some posts talking about the way I made creating blogs easier for me, so now I will talk a bit more, but this time about the blog layout itself.

I have made some changes to the CSS, as well as modifying some pages, such as the tags and blogs one. Up until the creation of this post, the blog archive has been a relatively small list of all of the blogs I’ve made. However, thinking about the future, I wanted to split all of this into sections, divided by year and month. To do that, a asked for suggestions on Mastodon. And of course, I got some replies. I ended up on Stack Overflow and found some ways to do what I wanted.

After a check there, I added the following lines to my file (located on my site’s root directory).

{% assign postsByYear = site.posts | group_by_exp:"post", " | date: '%Y'" %}
{% for year in postsByYear %}
  <h1>{{ }}</h1>
{% assign postsByMonth = year.items | group_by_exp:"post", " | date: '%B'" %}
{% for month in postsByMonth %}
<details><summary>{{ }}</summary>
  {% for post in month.items %}
   <a href="{{ post.url }}">{{ post.title }}</a><br>
	 {% for tag in post.tags %}
    <a class="posttag" href="/tags/{{ tag }}">{{ tag }}</a>  
	 {% endfor %}
		πŸ“… {{ | date: "%Y-%m-%d" }} <br>{{ post.description }}
  {% endfor %}
{% endfor %}
{% endfor %}

I made use of the nice <details> HTML element which is quite pretty thanks to Simple.css, the CSS framework I am using right now. I also used them to the tags page, which has a similar structure to the blog, although is quite simpler.

{% for tag in site.tags %}
  <summary>{{ tag[0] }}</summary>  
    {% for post in tag[1] limit:3 %}
      <p><a href="{{ post.url }}">{{ post.title }}</a> - πŸ“… {{ | date_to_string}} </p>
    {% endfor %}
  <a href="/tags/{{ tag[0] }}/" class="button">All posts</a> <a class="button" href="/feeds/{{ tag[0] }}.xml/">RSS</a>
{% endfor %}

Of course all of this might be quite weird and I am not going to pretend that I understand it all! I added tags a while ago and it took me some time to get the grasp of it. Remember that as a Jekyll SSG user it is my duty to let you all know of every little piece of liquid, HTML or ruby code I add to it!.

This was day 27 of #100DaysToOffload. Dont you love it when most of your blog consists of copy pasting already existing text and avoiding to explain most of it assuming your audience will understand it? I hope you did because I am done with this. I hope you read next one (and I hope its not as lazy)

If you want you can check more about this here:


If you have something to say, leave a comment, or contact me βœ‰οΈ instead

Reply via email Load comments
Reply via Fediverse

You can reply on any Fediverse (Mastodon, Pleroma, etc.) client by pasting this URL into the search field of your client: