Related Posts

{% if site.data.post.related.max %} {% assign maxRelated = site.data.post.related.max %} {% else %} {% assign maxRelated = 12 %} {% endif %} {% assign minCommonTags = 1 %} {% assign maxRelatedCounter = 0 %} {% assign allRelatedPosts = '' | split: ',' %} {% capture noRelatedPosts %}
No related post found
{% endcapture %} {% if site.posts.size < 1 %} {{ noRelatedPosts }} {% else %} {% for post in site.posts %} {% assign sameTagCount = 0 %} {% assign commonTags = '' %} {% for tag in post.tags %} {% if post.url != page.url %} {% if page.tags contains tag %} {% assign sameTagCount = sameTagCount | plus: 1 %} {% capture tagmarkup %} {{ tag }} {% endcapture %} {% assign commonTags = commonTags | append: tagmarkup %} {% endif %} {% endif %} {% endfor %} {% if sameTagCount >= minCommonTags %} {% assign allRelatedPosts = allRelatedPosts | push: post %} {% assign maxRelatedCounter = maxRelatedCounter | plus: 1 %} {% if maxRelatedCounter >= maxRelated %} {% break %} {% endif %} {% endif %} {% endfor %} {% if allRelatedPosts.size < 1 %} {{ noRelatedPosts }} {% else %}
{% for post in allRelatedPosts %}
{% if post.image %}
{% else %}
{% endif %}

{{ post.title | truncate: 50, '...' }}

{% endfor %}
{% endif %} {% endif %}