diff --git a/CHANGELOG.md b/CHANGELOG.md
index b09c39e6..f03fcf81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
- Auto scroll sticky ToC with content. [#3115](https://github.com/mmistakes/minimal-mistakes/pull/3115)
- Replace "hidden" check in Liquid templates with `where_exp: "item", "item.hidden != true"`.
- Remove deprecated `page.header.cta_url` setting. [#4821](https://github.com/mmistakes/minimal-mistakes/pull/4821)
+- Merge `categories` and `tags` layout into `_includes/posts-taxonomy.html`.
### Documentation & Maintenance
diff --git a/_includes/posts-taxonomy.html b/_includes/posts-taxonomy.html
new file mode 100644
index 00000000..e99db65c
--- /dev/null
+++ b/_includes/posts-taxonomy.html
@@ -0,0 +1,37 @@
+{% assign items_max = 0 %}
+{% for item in include.taxonomies %}
+ {% if item[1].size > items_max %}
+ {% assign items_max = item[1].size %}
+ {% endif %}
+{% endfor %}
+
+
+ {% for i in (1..items_max) reversed %}
+ {% for item in include.taxonomies %}
+ {% if item[1].size == i %}
+ -
+
+ {{ item[0] }} {{ i }}
+
+
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+
+
+{% assign entries_layout = page.entries_layout | default: 'list' %}
+{% for i in (1..items_max) reversed %}
+ {% for taxonomy in include.taxonomies %}
+ {% if taxonomy[1].size == i %}
+
+ {% endif %}
+ {% endfor %}
+{% endfor %}
diff --git a/_layouts/categories.html b/_layouts/categories.html
index ec9a6980..4d366118 100644
--- a/_layouts/categories.html
+++ b/_layouts/categories.html
@@ -4,40 +4,4 @@ layout: archive
{{ content }}
-{% assign categories_max = 0 %}
-{% for category in site.categories %}
- {% if category[1].size > categories_max %}
- {% assign categories_max = category[1].size %}
- {% endif %}
-{% endfor %}
-
-
- {% for i in (1..categories_max) reversed %}
- {% for category in site.categories %}
- {% if category[1].size == i %}
- -
-
- {{ category[0] }} {{ i }}
-
-
- {% endif %}
- {% endfor %}
- {% endfor %}
-
-
-{% assign entries_layout = page.entries_layout | default: 'list' %}
-{% for i in (1..categories_max) reversed %}
- {% for category in site.categories %}
- {% if category[1].size == i %}
-
- {% endif %}
- {% endfor %}
-{% endfor %}
+{% include posts-taxonomy.html taxonomies=site.categories %}
diff --git a/_layouts/tags.html b/_layouts/tags.html
index daa11828..a28fa5d7 100644
--- a/_layouts/tags.html
+++ b/_layouts/tags.html
@@ -4,40 +4,4 @@ layout: archive
{{ content }}
-{% assign tags_max = 0 %}
-{% for tag in site.tags %}
- {% if tag[1].size > tags_max %}
- {% assign tags_max = tag[1].size %}
- {% endif %}
-{% endfor %}
-
-
- {% for i in (1..tags_max) reversed %}
- {% for tag in site.tags %}
- {% if tag[1].size == i %}
- -
-
- {{ tag[0] }} {{ i }}
-
-
- {% endif %}
- {% endfor %}
- {% endfor %}
-
-
-{% assign entries_layout = page.entries_layout | default: 'list' %}
-{% for i in (1..tags_max) reversed %}
- {% for tag in site.tags %}
- {% if tag[1].size == i %}
-
- {% endif %}
- {% endfor %}
-{% endfor %}
+{% include posts-taxonomy.html taxonomies=site.tags %}
diff --git a/docs/_docs/18-history.md b/docs/_docs/18-history.md
index 2f746169..08d8ab35 100644
--- a/docs/_docs/18-history.md
+++ b/docs/_docs/18-history.md
@@ -5,7 +5,7 @@ permalink: "/docs/history/"
excerpt: Change log of enhancements and bug fixes made to the theme.
sidebar:
nav: docs
-last_modified_at: '2024-05-05T05:53:36+08:00'
+last_modified_at: '2024-05-05T14:13:21+08:00'
toc: false
---
@@ -27,6 +27,7 @@ toc: false
- Auto scroll sticky ToC with content. [#3115](https://github.com/mmistakes/minimal-mistakes/pull/3115)
- Replace "hidden" check in Liquid templates with `where_exp: "item", "item.hidden != true"`.
- Remove deprecated `page.header.cta_url` setting. [#4821](https://github.com/mmistakes/minimal-mistakes/pull/4821)
+- Merge `categories` and `tags` layout into `_includes/posts-taxonomy.html`.
### Documentation & Maintenance