This plugin adds a filter function pagination
that returns a list
of numbers from 1 to n and abbreviated with 0 if too long.
Enable the plugin in your pelicanconf.py:
PLUGINS = [ 'pagination' ]
Use the filter in a theme as follows:
<ul>
{% for cpage articles_paginator.num_pages | pagination(articles_page.number) %}
<li>
{% if cpage != 0 %}
<a href="{{ articles_paginator.page(cpage).url }}">{{ cpage }}</a>
{% else %}
<span>...</span>
{% endif %}
</li>
{% endfor %}
</ul>
The filter function is a modified version of the original in this stackexchange answer.