Created
May 31, 2015 12:55
-
-
Save satoyos/17b59bb858d81a069f83 to your computer and use it in GitHub Desktop.
Jekyll Related Posts without Plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% assign hasSimilar = '' %} | |
| {% for post in site.related_posts %} | |
| {% assign postHasSimilar = false %} | |
| {% for tag in post.tags %} | |
| {% for thisTag in page.tags %} | |
| {% if postHasSimilar == false and hasSimilar.size < 6 and post != page and tag == thisTag %} | |
| {% if hasSimilar.size == 0 %} | |
| <h4>Similar Posts</h4> | |
| <ul> | |
| {% endif %} | |
| <li class="relatedPost"> | |
| <a href="{{ site.url }}{{ post.url }}">{{ post.title }} | |
| {% if post.series %} | |
| (Series: {{ post.series }}) | |
| {% endif %} | |
| </a> | |
| </li> | |
| {% capture hasSimilar %}{{ hasSimilar }}*{% endcapture %} | |
| {% assign postHasSimilar = true %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endfor %} | |
| {% endfor %} | |
| {% if hasSimilar.size > 0 %} | |
| </ul> | |
| {% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment