Allows you find similar posts for your blog and add It's may be interested for you
links to your blog pages.
This is a plugin for the static site generation tool Pretzel.
To use this plugin you have to add configuration to _config.yml
. Typical configuration could be like this:
similar_posts:
filter_threshold: 0.3
related_count: 3
weight:
categories: 0.1
tags: 0.3
title: 0.2
text: 1
stemmers:
- English
- Russian
reserved:
- asp.net
- .net
- vs.net
Configuration parameters are:
filter_threshold
is param to define threshold for posts, it could be number from0
to1
.related_count
is param to define related posts count for each page.weight
is param to determine weight of different factors in comparision process. It accepts numbers from0
to1
. In this version the plugin is able to compare bycategory
,tag
,title
andtext
(blog post content).stemmers
is param to define which stemmers to use to pre-process the text. The plugin uses StemmersNet library for that. If you're using another language feel free to add additional languages availeable at StemmersNet.reserved
is param to define reserver words whcih won't be processed. During the comparision process all non-alphanumeric symbols will be removed. It's fine for most cases. But it's wrong for some situations likeasp.net
word. If we won't add it toreserved
list the plugin will understand it as two different wordsasp
andnet
, which is wrong. So we add it toreserved
list and plugin won't pre-process it at all.
Once we configure the plugin in _config.yml
there will be available page.related
variable for each page. To use it add code like this into your post.html
file:
{% if page.related.size > 0 -%}
<section class="related">
<h4>You may be interested in</h4>
<ul>
{% for page in page.related -%}
<li><a href="/{{page.url}}">{{page.title}}</a></li>
{% endfor -%}
</ul>
</section>
{% endif -%}
Download the latest release and extract Pretzel.SimilarPosts.zip
to the _plugins
folder at the root of your site folder.