{% assign MAX_SIZE = 3 %} {% assign TAG_SCORE = 1 %} {% assign CATEGORY_SCORE = 0.5 %} {% assign score_list = "" | split: "" %} {% assign post_index = 0 %} {% for post in site.posts %} {% if post.url != page.url %} {% assign score = 0 %} {% for tag in post.tags %} {% if page.tags contains tag %} {% assign score = score | plus: TAG_SCORE %} {% endif %} {% endfor %} {% for category in post.categories %} {% if page.categories contains category %} {% assign score = score | plus: CATEGORY_SCORE %} {% endif %} {% endfor %} {% if score > 0 %} {% capture score_item %}{{ score }}:{{ post_index }}{% endcapture %} {% assign score_list = score_list | push: score_item %} {% endif %} {% endif %} {% assign post_index = post_index | plus: 1 %} {% endfor %} {% unless score_list.size == 0 %} {% assign score_list = score_list | sort | reverse %} {% assign count = 0 %} {% endunless %}