Skip to content

Commit 4d95551

Browse files
add functionality to display categories, like tags, in blog home page (alshedivat#1482)
Added the functionality to display categories on the front page of the blog, just like tags.
1 parent aeee609 commit 4d95551

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ jekyll-archives:
263263
category: '/blog/category/:name/'
264264

265265
display_tags: ['formatting', 'images', 'links', 'math', 'code'] # these tags will be displayed on the front page of your blog
266+
display_categories: ['blockquotes'] # these categories will be displayed on the front page of your blog
266267

267268
# -----------------------------------------------------------------------------
268269
# Jekyll Scholar

_sass/_base.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ footer.sticky-bottom {
404404
}
405405
}
406406

407-
.tag-list {
407+
.tag-category-list {
408408
border-bottom: 1px solid var(--global-divider-color);
409409
text-align: center;
410410
padding-top: 1rem;

blog/index.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ <h2>{{ site.blog_description }}</h2>
2525
</div>
2626
{% endif %}
2727

28-
{% if site.display_tags %}
29-
<div class="tag-list">
28+
{% if site.display_tags or site.display_categories %}
29+
<div class="tag-category-list">
3030
<ul class="p-0 m-0">
3131
{% for tag in site.display_tags %}
3232
<li>
@@ -36,6 +36,17 @@ <h2>{{ site.blog_description }}</h2>
3636
<p>&bull;</p>
3737
{% endunless %}
3838
{% endfor %}
39+
{% if site.display_categories.size > 0 and site.display_tags.size > 0 %}
40+
<p>&bull;</p>
41+
{% endif %}
42+
{% for category in site.display_categories %}
43+
<li>
44+
<i class="fas fa-tag fa-sm"></i> <a href="{{ category | slugify | prepend: '/blog/category/' | relative_url }}">{{ category }}</a>
45+
</li>
46+
{% unless forloop.last %}
47+
<p>&bull;</p>
48+
{% endunless %}
49+
{% endfor %}
3950
</ul>
4051
</div>
4152
{% endif %}

0 commit comments

Comments
 (0)