Simple email obfuscation for Pelican

Posted on Sat, 26 Jul 2014

Updated on 27 Jul 2014

Simple email obfuscation for Pelican

Add these lines to your Pelican config file pelicanconf.py or publishconf.py:

EMAIL = 'yourmail@provider.com'
EMAIL_LINK = ''.join(('mailto:', EMAIL))
OBFUSCATED_EMAIL = ''.join(['&#{0:s};'.format(str(ord(char))) for char in EMAIL_LINK])

You can add this obfuscated email to the variable SOCIAL:

SOCIAL = (('Email', OBFUSCATED_EMAIL),)

The link is encoded in character entities and will appear like this in html:

<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#111;&#117;&#114;&#109;&#97;&#105;&#108;&#64;&#112;&#114;&#111;&#118;&#105;&#100;&#101;&#114;&#46;&#99;&#111;&#109;">Email</a>

But there should be no problem for the user to see it:

Email

You can even use the OBFUSCATED_EMAIL variable in your template.

It’s certainly not the best way to obfuscate your email, but it should limit the amount of spam you receive.

© octogene. Built using Pelican. Theme adapted from pelican-svbhack available on github.