Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information. Initial commit Feb 27, 2018 Initial commit Feb 27, 2018
demo.png Initial commit Feb 27, 2018

'pelican-readtime' - A Read Time Plugin for Pelican Static Site Generator

An article estimated read time plugin for Pelican static site generator. After Pelican generated the content of each page, the plugin read through the generated HTML content and strip all the tags, count all the word, then utilize average human read speed to calculate the read time of each article. The read time is passed over to the 'content' object of the article so Jinja template can use it to display the read time on wherever appropriate.


The plugin can be embedded into your site's template and look like this:
Pelican Read Time Demo
An example can be found in my own blog here.


This plugin only uses standard modules(re, html, math, etc), so no extra module installation like BeautifuSoup. To use it, just add the plugin name to the file.

    PLUGINS=[ ... , 'pelican-readtime']

Then you can put the following code in whichever template you what, like article.html.

    {% if article.readtime %}
    <div><b>Read in {{article.readtime.minutes}} min.</b></div>
    {% endif %}

You can also add some styling to it like so:

    {% if article.readtime %}
    <span><p style="text-align:right; color:#aaaaaa; ">&nbsp Estimated read time: {{article.readtime.minutes}} min.</p></span>
    {% endif %}


This is a revised version of jmaister's readtime plugin. I added some more comments and tweaked the code so it runs smoothly on Python 3.6


[1] Wikipedia - Words per minute
[2] Medium - Read Time