<!-- Copied from https://blog.webjeda.com/jekyll-related-posts/ -->

<div class="relatedPosts">

    <h4>You May Also Enjoy</h4>

    {% assign maxRelated = 4 %}
    {% assign minCommonTags =  2 %}
    {% assign maxRelatedCounter = 0 %}

    {% 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 %}
    {% endif %}
    {% endif %}
    {% endfor %}

    {% if sameTagCount >= minCommonTags %}
    <div>
        <h5>{{ post.date |  date: "%m/%d/%Y" }} - <a href="{{ post.url }}">{{ post.title }}</a></h5>
    </div>
    {% assign maxRelatedCounter = maxRelatedCounter | plus: 1 %}
    {% if maxRelatedCounter >= maxRelated %}
    {% break %}
    {% endif %}
    {% endif %}

    {% endfor %}

</div>
    <h4>You May Also Enjoy</h4>
    {% assign related = site.tags.[page.tags] %}
    {% for post in related %}

    <div>
        <h5>{{ post.date |  date: "%m/%d/%Y" }} - <a href="{{ post.url }}">{{ post.title }}</a></h5>
    </div>

    {% endfor %}

Switch back to my way
Switch back to my way
