diff --git a/archives.md b/archives.md
index 9f8e777b..6e56f716 100644
--- a/archives.md
+++ b/archives.md
@@ -7,12 +7,6 @@ title: Archives
{% year_utilities years_with_month_links %}
Category based archives
-{% capture category_names %}
- {% for category in site.categories %}|{{ category | first }}{% endfor %}
-{% endcapture %}
+{% capture category_names %}{% for category in site.categories %}|{{ category | first }}{% endfor %}{% endcapture %}
{% assign sorted_category_names = category_names | split: '|' | sort %}
-{% for category_name in sorted_category_names %}
- {% if category_name != "" %}
- {{category_name}}{% unless forloop.last %}, {% endunless %}
- {% endif %}
-{% endfor %}
+{% for category_name in sorted_category_names %}{% if category_name | strip != "" %}{{category_name}}{% unless forloop.last %}, {% endunless %}{% endif %}{% endfor %}