Skip to main content

Pull Requests Welcome build status Pypi latest version License: AGPL v3

Pelican plugin implementing Linkback protocols, on the linking server side. More information in this blog article.

Protocols currently implemented:

❌ Refback: won't be implemented because it requires to retrieve the HTTP Referer header, which cannot be done by Pelican, a static blog engine

❌ TalkBack: won't be implemented because it did not gain enough popularity / traction since its birth in 2011

❌ Trackback (protocol spec): won't be implemented because it does not seem widely used, and requires to parse embedded RDF documents (enclosed in HTML comments as a fallback), which seems a poor design in an era of HTML5 / RDFa

Do not hesitate to suggest other protocols, or report your experience with this plugin, by submitting an issue.

What are linkbacks?

A linkback is a method for Web authors to obtain notifications when other authors link to one of their documents. This enables authors to keep track of who is linking to, or referring to, their articles. The four methods (Refback, Trackback, Pingback and Webmention) differ in how they accomplish this task.

I invite you to read this Wikipedia page for more information & links: Linkback

What does this plugin do?

For every hyperlink in your articles, this plugin will notify their hosting websites (just those supporting a Linkback protocol) of those references.

This plugin does not perform inclusion of Linkbacks in your articles / as comments, for every website referencing your content following a Linkback protocol, because this cannot be performed by a static website generator like Pelican.

When you enable this plugin the first time, it will process all the hyperlinks of your existing articles. It will do it only once, and then create a cache file to avoid processing those links next time. Still, because the publish step will be longer than usual the first time you enable this plugin, I recommend to use pelican -D flag to get debug logs, and hence follow the plugin progress.

Installation / setup instructions

To enable this plugin:

  1. Install the package from Pypi: pip install pelican-plugin-linkbacks
  2. Add the plugin to your publishconf.py:
PLUGINS = [..., 'linkbacks']

Cache

In order to avoid the repetitive CPU / bandwidth cost of repeatedly performing links parsing & linkback notifications, this hook only proceed to do so once, the first time an article is published.

In order to do so, it uses a very simple and small cache that contains the list of all hyperlinks already parsed, per article slug.

To remove a blog entry from cache, in order for the plugin to retry sending a linkback:

jq "del(.['$slug'])" pelican-plugin-linkbacks.json | sponge pelican-plugin-linkbacks.json

Configuration

Available options:

  • LINKBACKS_CACHEPATH (optional, default: $CACHE_PATH/pelican-plugin-linkbacks.json, where $CACHE_PATH is a Pelican setting) : the path to the JSON file containg this plugin cache (a list of URLs already processed).
  • LINKBACKS_USERAGENT (optional, default: pelican-plugin-linkbacks) : the User-Agent HTTP header to use while sending notifications.
  • LINKBACKS_CERT_VERIFY (optional, default: False) : enforce HTTPS certificates verification when sending linkbacks
  • LINKBACKS_REQUEST_TIMEOUT (optional, in seconds, default: 3) : time in seconds allowed for each HTTP linkback request before abandon

Manual execution

The linkbacks.py module can be used as script to test this plugin behavior:

export SITEURL=...
python path/to/pelican/plugins/linkbacks/linkbacks.py $pelican_generated_html_file

Optionally the colorama package can be installed to get colored logs in the output.

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.

Releasing a new version

With a valid configuration in ~/.config/pypoetry/:

  1. update CHANGELOG.md
  2. bump version in pyproject.toml
  3. poetry build && poetry publish
  4. perform a release on GitGub, including the description added to CHANGELOG.md

Linter & tests

To execute them:

pylint pelican/plugins/linkbacks/
pytest

Integration tests

You'll find some advices & resources on indieweb.org: pingback page, webmention page.

For WebMentions specifically, the webmention.io service can be useful.

For Pingbacks, I used for my tests a Wordpress instance launched with Docker:

docker run --rm -p 80:80 -e WORDPRESS_DB_HOST=host.docker.internal -e WORDPRESS_DB_USER=... -e WORDPRESS_DB_PASSWORD=... wordpress

From my experience, you'll also have to:

  • configure a local MySQL database to accept connections from $WORDPRESS_DB_USER:$WORDPRESS_DB_PASSWORD
  • configure the xmlrpc_pingback_error Wordpress filter to be passthrough, to get useful error messages
  • configure the http_request_host_is_external Wordpress filter to always return true, so that it won't reject host.docker.internal links

Wordpress client source code related to XML-RPC pingbacks can be found there:

Metadata

Release files for pelican-plugin-linkbacks 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pelican-plugin-linkbacks 1.0.6
File Size Uploaded
pelican_plugin_linkbacks-1.0.6.tar.gz 25.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pelican-plugin-linkbacks 1.0.6
File Interpreter ABI Platform
pelican_plugin_linkbacks-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 51.0 kB

Release files / pelican_plugin_linkbacks-1.0.6.tar.gz

Download URL pelican_plugin_linkbacks-1.0.6.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9c2622edf594fc74c1aeb0eb4c8c02ff7285eee6124ea0702a9a963c68ad41fa
BLAKE2b-256 checksum
How to use checksums
05293905177bfea596e7575a2b1c723f76dbe2753877e8819dab52e0cabec071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2

Release files / pelican_plugin_linkbacks-1.0.6-py3-none-any.whl

Download URL pelican_plugin_linkbacks-1.0.6-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e0c47fb49ea9d1e1026aaf68f8e5f09c96fcc01ead350bb22ee3dc81de32af7
BLAKE2b-256 checksum
How to use checksums
12d97f898261d19d0f7401ca0df6fccb8c9851e7d70a3249ad1f1cc2afccaa15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page