diff --git a/_layouts/tags.html b/_layouts/tags.html
index 1c0e70231..128e176e4 100644
--- a/_layouts/tags.html
+++ b/_layouts/tags.html
@@ -4,13 +4,14 @@
{{ content }}
+{% assign tags_max = 0 %}
+{% for tag in site.tags %}
+ {% if tag[1].size > tags_max %}
+ {% assign tags_max = tag[1].size %}
+ {% endif %}
+{% endfor %}
+
- {% 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 %}
@@ -24,13 +25,6 @@
{% endfor %}
-{% 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 %}