14mC4
November 26, 2022, 8:08pm
1
How would I go about creating a seperate section of a blog using Jekyll?
For example, above I have a section titled HTB and I want it to function just like the blog posts but, only have tagged “htb” posts within it.
Current Setup and Repo GitHub - 14mC4/14mC4.github.io
You can use a modified version of the layout post of Minimal Mistakes selecting the desired posts with where_exp: "item", "item.tags contains 'HTB'"
Create an htb.md
file with:
---
title: "HTB posts"
layout: archive
permalink: /htb/
---
<ul class="taxonomy__index">
{% assign postsInYear = site.posts | where_exp: "item", "item.tags contains 'HTB'" | where_exp: "item", "item.hidden != true" | group_by_exp: 'post', 'post.date | date: "%Y"' %}
{% for year in postsInYear %}
<li>
<a href="#{{ year.name }}">
<strong>{{ year.name }}</strong> <span class="taxonomy__count">{{ year.items | size }}</span>
</a>
</li>
{% endfor %}
</ul>
{% assign entries_layout = page.entries_layout | default: 'list' %}
{% assign postsByYear = site.posts | where_exp: "item", "item.tags contains 'HTB'" | where_exp: "item", "item.hidden != true" | group_by_exp: 'post', 'post.date | date: "%Y"' %}
{% for year in postsByYear %}
<section id="{{ year.name }}" class="taxonomy__section">
<h2 class="archive__subtitle">{{ year.name }}</h2>
<div class="entries-{{ entries_layout }}">
{% for post in year.items %}
{% include archive-single.html type=entries_layout %}
{% endfor %}
</div>
<a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} ↑</a>
</section>
{% endfor %}
See Live Demo
2 Likes
14mC4
November 27, 2022, 4:44pm
4
Thanks for the PR as well as quick response. Not very familiar with Jekyll but, really love the simplicity. Very fluid and works perfect for me. I was curious. I had seem other blogs do similar but, perfect. Thanks Again.
1 Like