Package: pelican-ab
This is an A/B testing plugin for Pelican. It allows you to encode
experiments in your templates and renders the experiment selected by
theAB_EXPERIMENTenvironment variable. ‘control’ is the default
experiment name ifAB_EXPERIMENTis not specified!To install:pip install pelican-abEnable the plugin inpelicanconf.pylike this:PLUGIN_PATHS = ['path/to/pelican-ab']
PLUGINS = ['pelican_ab']PLUGIN_PATHScan be a path relative to your settings file or an absolute
path. Alternatively, if plugins are in an importable path, you can omitPLUGIN_PATHSand list them:PLUGINS = ['pelican_ab']or you canimportthe plugin directly and give the module name instead:import pelican_ab
PLUGINS = [pelican_ab]The template syntax is provided by thejinja-abextension
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!How to test and publish experimentsFor local development use the command:AB_EXPERIMENT="xy" make regenerateor:AB_EXPERIMENT="xy" make htmltogether withmake serveto review the experiments.
When you are ready to publish them online use:rm -rf output/
make github
AB_EXPERIMENT="01" make github
AB_EXPERIMENT="02" make githubSee the section aboutDELETE_OUTPUT_DIRECTORYfor more info.Output filesAfter encoding your experiments into the theme templates you can generate the
resulting HTML files like this:AB_EXPERIMENT="v1" make htmlWhen rendering experiments the resulting HTML files are saved underOUTPUT_PATHplus the experiment name. For example ‘output/v1’, ‘output/v2’,
etc. The control experiments are rendered directly underOUTPUT_PATH.This plugin automatically updates theContent.urlandURLWrapper.urlclass 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’.DELETE_OUTPUT_DIRECTORYBy defaultpublishconf.pyhasDELETE_OUTPUT_DIRECTORYset to True
which causes pelican-ab to raise an exception. The problem is that you need to
executemake publishormake githubfor each experiment you’d like to
publish online. WhenDELETE_OUTPUT_DIRECTORYis True the previous
contents will be deleted andONLYthat variation will be published!
This will break your website because everything will be gone!CHANGELOGv0.2.4 (Dec 25th 2016)add more testsenable pylint during testingfix badsuper()callv0.2.3 (Dec 13th 2016)rebuilt for Pelican v3.7.0 which now expects
Jinja2 extensions in theJINJA_ENVIRONMENTsetting instead ofJINJA_EXTENSIONS.v0.2.2 (May 12th 2016)raise RuntimeError ifDELETE_OUTPUT_DIRECTORYis set to Truev0.2.1 (May 11th 2016)updated READMEv0.2.0 (May 10th 2016)initial releaseContributingSource code and issue tracker are athttps://github.com/MrSenko/pelican-abCommercial supportMr. Senkoprovides commercial support for open source
libraries, should you need it!