diff --git a/_layouts/single.html b/_layouts/single.html
index 6e16cfc1..9135de71 100644
--- a/_layouts/single.html
+++ b/_layouts/single.html
@@ -66,28 +66,30 @@ layout: default
{% endif %}
- {% comment %}{% endcomment %}
- {% if page.id and page.related and site.related_posts.size > 0 %}
-
-
{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}
-
- {% for post in site.related_posts limit:4 %}
- {% include archive-single.html type="grid" %}
- {% endfor %}
-
-
- {% comment %}{% endcomment %}
- {% elsif page.id and page.related %}
-
-
{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}
-
- {% for post in site.posts limit:4 %}
- {% if post.id == page.id %}
- {% continue %}
+ {% comment %}{% endcomment %}
+ {% if page.related %}
+ {% assign n_posts = 0 %}
+ {% for post in site.posts %}
+ {% if post.id == page.id %}{% continue %}{% endif %}
+ {% for this_category in page.categories %}
+ {% if post.categories contains this_category %}
+ {% if n_posts == 0 %}
+
+ {% if site.data.ui-text[site.locale].related_label %}
+
{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}
+ {% endif %}
+
+ {% endif %}
+ {% include archive-single.html type="grid" %}
+ {% assign n_posts = n_posts | plus: 1 %}
+ {% break %}
{% endif %}
- {% include archive-single.html type="grid" %}
- {% endfor %}
+ {% endfor %}
+ {% if n_posts > 3 %}{% break %}{% endif %}
+ {% endfor %}
+ {% if n_posts > 0 %}
+
-
+ {% endif %}
{% endif %}