Libravatar/Gravatar plugin for Pelican
Project description
Avatar: A Plugin for Pelican
This plugin allows the inclusion of Libravatar or Gravatar user profile pictures, corresponding to the email address of the article's author.
Installation
This plugin can be installed via:
python -m pip install pelican-avatar
As long as you have not explicitly added a PLUGINS setting to your Pelican settings file, the newly-installed plugin should be detected and enabled automatically. Otherwise, you must add avatar to your existing PLUGINS list. For more information, please refer to the How to Use Plugins documentation.
Usage
Specifying the Author's Email Address
The default email address is taken from the AVATAR_AUTHOR_EMAIL variable in the Pelican settings file. This default value can be overridden on a per-article basis by specifying an email address in the article's metadata:
For reStructuredText:
:email: bart.simpson@example.com
For Markdown:
Email: bart.simpson@example.com
First, the plugin tries to find a corresponding avatar image for the specified email at Libravatar. If it is not found there, the plugin searches Gravatar. If an avatar is not found at either service, a default picture is shown. The “missing picture” default can be defined in the configuration variable AVATAR_MISSING.
Adjusting the Template
This plugin assigns the author_avatar variable to the avatar image URL and makes that variable available within the article's context. For instance, you can add the following code to a template file, such as the article_infos.html template file, just before the author information:
{% if article.author_avatar %}
<div align="center">
<img src="{{ article.author_avatar }}">
</div>
{% endif %}
This will yield the following result (with the notmyidea theme):
Page templates work in a similar way:
{% if page.author_avatar %}
<div align="center">
<img src="{{ page.author_avatar }}">
</div>
{% endif %}
To use in common templates, such as base.html, you can do something like this:
{% if author_avatar %}
<div align="center">
<img src="{{ author_avatar }}">
</div>
{% endif %}
If you want to allow the email address to be overridden in articles or pages while still using the global configuration if neither is available, you can do so:
{% if article and article.author_avatar %}
{% set author_avatar = article.author_avatar %}
{% elif page and page.author_avatar %}
{% set author_avatar = page.author_avatar %}
{% endif %}
{% if author_avatar %}
<div align="center">
<img src="{{ author_avatar }}">
</div>
{% endif %}
Configuration
The following variables can be configured in the Pelican settings file:
-
AVATAR_AUTHOR_EMAIL: The site-wide default for the author's email address. -
AVATAR_MISSING: The default for the missing picture. It can be either a URL (e.g.,"http://example.com/nobody.png") or the name of a logo library (e.g.,"wavatar". For the full set of alternatives, see the Libravatar API). -
AVATAR_SIZE: The size, in pixels, of the profile picture (it is always square, so the height is equal to the width). If not specified, the default size (80×80) is returned by Libravatar. -
AVATAR_USE_GRAVATAR: The plugin looks up avatars via the Libravatar service by default. Searching the Gravatar service can be forced by setting this configuration variable toTrue.
Credits
The inspiration for this plugin came from the Gravatar plugin.
Contributing
Contributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on existing issues.
To start contributing to this plugin, review the Contributing to Pelican documentation, beginning with the Contributing Code section.
Acknowledgments
Thanks to Justin Mayer for helping migrate of this plugin under the Pelican Plugins organization, to Troy Curtis for adding support for page and global generator context and for improving the Poetry workflow (even though we are now using PDM), to Lucas Cimon for fixing the test suite and providing CI support, and to Christian Clauss for the Python 3 port.
Author
Copyright (C) 2015, 2021-2025 Rafael Laboissière (rafael@laboissiere.net)
License
This project is licensed under the terms of the AGPL 3.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pelican_avatar-1.0.11.tar.gz.
File metadata
- Download URL: pelican_avatar-1.0.11.tar.gz
- Upload date:
- Size: 142.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed0e14510e19f0905602af33091e4ef3795ea3b71f19f83f5153094f9ff5d911
|
|
| MD5 |
b0f09e06cd864cdf7928f70714d6f4df
|
|
| BLAKE2b-256 |
91bf79507be4222d7846dbdd29a77c1d60a13d8dbf77e1cc2781bf304bdd6487
|
Provenance
The following attestation bundles were made for pelican_avatar-1.0.11.tar.gz:
Publisher:
main.yml on pelican-plugins/avatar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pelican_avatar-1.0.11.tar.gz -
Subject digest:
ed0e14510e19f0905602af33091e4ef3795ea3b71f19f83f5153094f9ff5d911 - Sigstore transparency entry: 691272558
- Sigstore integration time:
-
Permalink:
pelican-plugins/avatar@7f18e7621e54d1abb6bbd793c9453bae305cdbd5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pelican-plugins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@7f18e7621e54d1abb6bbd793c9453bae305cdbd5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pelican_avatar-1.0.11-py3-none-any.whl.
File metadata
- Download URL: pelican_avatar-1.0.11-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
823cb7ec323ad4537ee7ffd6aef3472e49720558192fda187f6e59aa94065249
|
|
| MD5 |
92f87062cc27661505b2b2a67a2a5214
|
|
| BLAKE2b-256 |
b8cc57f5d199657c7b1f445ca4cc360f5cd4c0d3a2a9793f6cac44f52fb3391f
|
Provenance
The following attestation bundles were made for pelican_avatar-1.0.11-py3-none-any.whl:
Publisher:
main.yml on pelican-plugins/avatar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pelican_avatar-1.0.11-py3-none-any.whl -
Subject digest:
823cb7ec323ad4537ee7ffd6aef3472e49720558192fda187f6e59aa94065249 - Sigstore transparency entry: 691272593
- Sigstore integration time:
-
Permalink:
pelican-plugins/avatar@7f18e7621e54d1abb6bbd793c9453bae305cdbd5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pelican-plugins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@7f18e7621e54d1abb6bbd793c9453bae305cdbd5 -
Trigger Event:
push
-
Statement type: