Even T
Even T

Reputation: 31

Python Pelican - interlink posts

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:

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

Upvotes: 1

Views: 448

Answers (4)

MinchinWeb
MinchinWeb

Reputation: 706

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.

Upvotes: 1

MinchinWeb
MinchinWeb

Reputation: 706

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:

<!-- end of article -->

[Previous Post]({filename}article-slug1.md) --
[Next Post]({filename}more-articles-slug.md)

This will result in two links, one to the previous article and one to the next article, and the end of your post.

Upvotes: 0

Flobin
Flobin

Reputation: 708

I am not sure about the random article, but for next and previous, there is a Pelican plugin called neighbor articles.

Upvotes: 0

Related Questions