Now that I have converted TechTinkering over to Jekyll, I have come up against a bit of a problem with
site.related_posts: The results are always just the latest posts, and are not filtered or ordered for relevance. I see that lots of people are struggling with a similar problem and have therefore decided to write a plugin which will improve it. Because the posts on this site make use of tags, I decided to match against those to assess relevance.
I was in two minds as to how to structure this plugin: whether to write a straight monkey patch, or whether to put it in a module and include it. I went with the latter as I have heard a lot of talk about this being the preferred route to ease debugging. However it doesn’t seem quite right because I have had to force the removal of the old
related_posts method to do so. If anyone has any suggestions on this, then please leave a comment here or via the GitHub repo.
At the time of writing, the
related_posts.rb plugin file looks like this:
Please look at the README file for the latest instructions.
- Download the latest version of the plugin from the related_posts-jekyll_plugin repository
The plugin replaces the functionality of
site.related_posts so you
can use it as follows: