In Jekyll set a variable for the mail, e.g. in the _config.yml
email: [email protected]
then use it in your page
Reach me under: {{ site.email | mailObfuscate }}
which will generate the following HTML
<a href="#" data-contact="bmFtZUBtYWlsLmNvbQ== " target="_blank" onfocus="this.href = 'mailto:' + atob(this.dataset.contact)">
<script type="text/javascript">document.write(atob("bmFtZUBtYWlsLmNvbQ== "));</script>
</a>
This uses some simple obfuscation techniques of url encode and base64 encode the mail and use JS to support the link and write it to HTML programmatically. This is certainly not bulletproof, but a good shield and in combination with a good spam filter this will fix your problem with mail crawlers.
These techniques are partly from http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared/
Here is how you do it:
mail_obfuscate.rb
in a folder named_plugins
(create it if it does not exist). Every script in this folder will be loaded before the rest of the plugins.{{ site.email | mailObfuscate }}
wherever you would like to have your email.It did not work for me at first. It turns out the
github-pages
gem is causing Jekyll to run in safe mode. You would have to replace this gem withjekyll
in order for it to work.