Enhancing Content Discoverability with Related Posts Plugin for Pelican
Are you looking for a way to improve content discoverability on your Pelican-based website? Look no further! The Related Posts plugin for Pelican is here to help. This plugin adds a list of related articles to each post, increasing engagement and helping users navigate through your content seamlessly.
Installation
Getting started with the Related Posts plugin is easy. You can install it via pip by running the following command:
python -m pip install pelican-related-posts
Usage
Once you have installed the plugin, you can customize the number of related articles displayed in the list. By default, up to five related articles are listed. To change this value, define the RELATED_POSTS_MAX
variable in your settings file. For example, if you want to display up to 10 related articles, add the following line to your settings file:
RELATED_POSTS_MAX = 10
To display the list of related articles in your templates, use the article.related_posts
variable. You can iterate over this variable in a for
loop and create a list with links to the related articles, like this:
html
{% if article.related_posts %}
<ul>
{% for related_post in article.related_posts %}
<li><a href="{{ SITEURL }}/{{ related_post.url }}">{{ related_post.title }}</a></li>
{% endfor %}
</ul>
{% endif %}
To ensure accurate related posts, make sure that your related posts share a common tag. You can specify these tags in your post’s meta-data by using the related_posts:
field. For example, if you have posts with slugs “slug1”, “slug2”, and “slug3” that are related to the current post, add the following line to your post’s meta-data:
related_posts: slug1, slug2, slug3
Advanced Features
The Related Posts plugin provides additional customization options in the settings file. By setting RELATED_POSTS_SKIP_SAME_CATEGORY
to True
, the article.related_posts
variable will only contain related posts from categories other than the original article’s category.
Contributing
Contributions to the Related Posts plugin are welcome and highly appreciated. Whether you want to improve the documentation, add missing features, or fix bugs, your contribution will make a difference. You can also contribute by reviewing and commenting on existing issues. To get started, refer to the Contributing to Pelican documentation, which provides guidelines for contributing code.
Enhance the discoverability of your content with the Related Posts plugin for Pelican. Start using this plugin today and see the engagement and navigation on your website improve significantly.
If you have any questions or need further assistance, please feel free to ask. Happy content discovering!
Leave a Reply