Jekyll plugin to show related posts based on the content, tags, and categories. The similarity is calculated using TF-IDF(term frequency-inverted document frequency). Since tags and categories are use-defined values, those are considered with higher weights than a content while calculating.
- Install the gem
jekyll-tfidf-related-posts
.
$ gem install jekyll-tfidf-related-posts
- Add
jekyll-tfidf-related-posts
plugin in_config.xml
.
plugins:
- jekyll-tfidf-related-posts
- Run
jekyll build
orjekyll serve
This plugin calculates related posts and replaces site.related_posts
containing recent 10 posts by default. So, you can render related posts by iterating site.related_posts
.
{% for post in site.related_posts %}
{% include related-post.html %}
{% endfor %}
GitHub Pages supports only these plugins. For GitHub Pages, you need to generate your site locally and then push static files to GitHub Pages site.
By default, there are 4 related posts. You can configure it in the _config.yml
related_posts_count: 8