Support A/B testing for Pelican
Project description
This is an A/B testing plugin for Pelican. It allows you to encode experiments in your templates and renders the experiment selected by the AB_EXPERIMENT environment variable. ‘control’ is the default experiment name if AB_EXPERIMENT is not specified!
To install:
pip install pelican-ab
Enable the plugin in pelicanconf.py like this:
PLUGIN_PATHS = ['path/to/pelican-ab'] PLUGINS = ['pelican_ab']
PLUGIN_PATHS can be a path relative to your settings file or an absolute path. Alternatively, if plugins are in an importable path, you can omit PLUGIN_PATHS and list them:
PLUGINS = ['pelican_ab']
or you can import the plugin directly and give the module name instead:
import pelican_ab PLUGINS = [pelican_ab]
The template syntax is provided by the jinja-ab extension which is automatically loaded:
{% experiment control %}This is the control{% endexperiment %} {% experiment v1 %}This is version 1{% endexperiment %}
Alternative syntax is also supported:
{% ab control %}This is the control{% endab %} {% ab v1 %}This is version 1{% endab %}
You can also mix the two tags in a single template:
{% experiment control %}This is the control{% endexperiment %} {% ab v1 %}This is version 1{% endab %}
Single and double quoted names are also supported!
Output files
When rendering experiments the resulting HTML files are saved under OUTPUT_PATH plus the experiment name. For example ‘output/v1’, ‘output/v2’, etc. The control experiments are rendered directly under OUTPUT_PATH.
This plugin automatically updates the Content.url and URLWrapper.url class properties from Pelican so that things like {{ article.url }} and {{ author.url }} will point to URLs from the same experiment. In other words each experiment produces its own HTML and URL structure, using the experiment name as prefix. For example ‘blog/about-me.html’ becomes ‘v1/blog/about-me.html’.
Contributing
Source code and issue tracker are at https://github.com/MrSenko/pelican-ab
Commercial support
Mr. Senko provides commercial support for open source libraries, should you need it!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pelican-ab-0.2.1.tar.gz
.
File metadata
- Download URL: pelican-ab-0.2.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f5d5f04a38a1f1184bb49f272c60fd20db4555e61f278aeac238cbabeb5fab0 |
|
MD5 | 7d79c67d185f95faed8fc24f58ef95a8 |
|
BLAKE2b-256 | 11d37dfb73084c21f10ea07f935c843b65183158478d3fce47ae616fda565a23 |