I have a Pelican blog where I write the posts in Markdown. I want each article to link to the previous and next article in the sequence, and to one random article.
All the articles are generated with a python script, resulting in a folder of markdown files called /content/. Here the files are like:
- article-slug1.md
- another-article-slug.md
- more-articles-slug.md
- […]
Is there a token I can add to the markdown to randomly interlink/link to next/previous? If not, how can I set this up in python?
Thanks in advance
4
Answers
I am not sure about the random article, but for next and previous, there is a Pelican plugin called neighbor articles.
Random article:https://github.com/getpelican/pelican-plugins/tree/master/random_article
More pelican plugins: https://github.com/getpelican/pelican-plugins
If you are generating all your posts programatically, is it safe to assume that your generation script knows what the next and previous articles? If this is the case, then you can write the links in directly in your generated markdown.
E.g. at the end of
another-article-slug.md
add the lines:This will result in two links, one to the previous article and one to the next article, and the end of your post.
There is the Pelican Neighbours plug-in that might do what you want. You’ll have to active the plug-in and update your template to get it to work.