From 1889b6b4e07d4ab8eb38b2eb1b09c01d296e6c39 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 18 Nov 2020 23:16:09 +0800 Subject: [PATCH] Using `jekyll-archives` to create category/tag pages. --- Gemfile | 1 + _config.yml | 11 ++++++++++- _layouts/category.html | 6 +++--- _layouts/tag.html | 6 +++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 7a2f050..5825b0d 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ group :jekyll_plugins do gem "jekyll-paginate" gem "jekyll-redirect-from" gem "jekyll-seo-tag", "~> 2.6.1" + gem "jekyll-archives" end group :test do diff --git a/_config.yml b/_config.yml index 8995311..b18e3fd 100644 --- a/_config.yml +++ b/_config.yml @@ -161,7 +161,6 @@ defaults: label: Home url: / - sass: sass_dir: /assets/css style: compressed @@ -198,3 +197,13 @@ sitemap_exclude: # Sitemap will exclude the following items. - sitemap.xml - robots.txt - redirects.json + +# see: +jekyll-archives: + enabled: [categories, tags] + layouts: + category: category + tag: tag + permalinks: + tag: '/tags/:name/' + category: '/categories/:name/' diff --git a/_layouts/category.html b/_layouts/category.html index 70fec40..ccc7d46 100644 --- a/_layouts/category.html +++ b/_layouts/category.html @@ -10,11 +10,11 @@ layout: page

{{ page.title }} - {{ site.categories[page.category] | size }} + {{ page.posts | size }}

- \ No newline at end of file + diff --git a/_layouts/tag.html b/_layouts/tag.html index 646162d..1e67f6e 100644 --- a/_layouts/tag.html +++ b/_layouts/tag.html @@ -11,10 +11,10 @@ layout: page

{{ page.title }} - {{ site.tags[page.tag] | size }} + {{ page.posts | size }}

- \ No newline at end of file +