aboutsummaryrefslogtreecommitdiff
path: root/plugins/related_posts/Readme.rst
blob: 0edf4bd8b71af02895adc3dc03a199e32feafa07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Related posts
-------------

**NOTE:** `This plugin has been moved to its own repository <https://github.com/pelican-plugins/related-posts>`_. Please file any issues/PRs there. Once all plugins have been migrated to the `new Pelican Plugins organization <https://github.com/pelican-plugins>`_, this monolithic repository will be archived.

-------------------------------------------------------------------------------

This plugin adds the ``related_posts`` variable to the article's context.
By default, up to 5 articles are listed. You can customize this value by 
defining ``RELATED_POSTS_MAX`` in your settings file::

    RELATED_POSTS_MAX = 10

You can then use the ``article.related_posts`` variable in your templates.
For example::

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


Your related posts should share a common tag. You can also use ``related_posts:`` in your post's meta data.
The 'related_posts:' meta data works together with your existing slugs::

    related_posts: slug1, slug2, slug3, ... slugN

``N`` represents the ``RELATED_POSTS_MAX``.

Additionally, you can specify::

    RELATED_POSTS_SKIP_SAME_CATEGORY = True

in your settings file. With this setting, ``article.related_posts`` will
contain only related posts from categories other than the original article's.