Skip to content

Commit b3fc096

Browse files
committed
Using jekyll-archives to create category/tag pages.
1 parent dd3bf37 commit b3fc096

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

Diff for: Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ group :jekyll_plugins do
77
gem "jekyll-paginate"
88
gem "jekyll-redirect-from"
99
gem "jekyll-seo-tag", "~> 2.6.1"
10+
gem "jekyll-archives"
1011
end
1112

1213
group :test do

Diff for: _config.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ defaults:
161161
label: Home
162162
url: /
163163

164-
165164
sass:
166165
sass_dir: /assets/css
167166
style: compressed
@@ -198,3 +197,13 @@ sitemap_exclude: # Sitemap will exclude the following items.
198197
- sitemap.xml
199198
- robots.txt
200199
- redirects.json
200+
201+
# see: <https://github.com/jekyll/jekyll-archives/blob/master/docs/configuration.md>
202+
jekyll-archives:
203+
enabled: [categories, tags]
204+
layouts:
205+
category: category
206+
tag: tag
207+
permalinks:
208+
tag: '/tags/:name/'
209+
category: '/categories/:name/'

Diff for: _layouts/category.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
<h1 class="pl-lg-2">
1111
<i class="far fa-folder-open fa-fw text-muted"></i>
1212
{{ page.title }}
13-
<span class="lead text-muted pl-2">{{ site.categories[page.category] | size }}</span>
13+
<span class="lead text-muted pl-2">{{ page.posts | size }}</span>
1414
</h1>
1515

1616
<ul class="post-content pl-0">
17-
{% for post in site.categories[page.category] %}
17+
{% for post in page.posts %}
1818
<li class="d-flex justify-content-between pl-md-3 pr-md-3">
1919
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
2020
<span class="dash flex-grow-1"></span>
2121
<span class="text-muted small">{{ post.date | date: site.data.date_format.post.long }}</span>
2222
</li>
2323
{% endfor %}
2424
</ul>
25-
</div>
25+
</div>

Diff for: _layouts/tag.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
<h1 class="pl-lg-2">
1212
<i class="fa fa-tag fa-fw text-muted"></i>
1313
{{ page.title }}
14-
<span class="lead text-muted pl-2">{{ site.tags[page.tag] | size }}</span>
14+
<span class="lead text-muted pl-2">{{ page.posts | size }}</span>
1515
</h1>
1616
<ul class="post-content pl-0">
17-
{% for post in site.tags[page.tag] %}
17+
{% for post in page.posts %}
1818
<li class="d-flex justify-content-between pl-md-3 pr-md-3">
1919
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
2020
<span class="dash flex-grow-1"></span>
2121
<span class="text-muted small">{{ post.date | date: site.data.date_format.post.long }}</span>
2222
</li>
2323
{% endfor %}
2424
</ul>
25-
</div>
25+
</div>

0 commit comments

Comments
 (0)