A Hugo theme component to cloak email adresses
This Hugo theme component provides a shortcode.
Shortcode cloakemail
cloakes e-mail or other messaging (xmpp
, tg
, etc.) or phone (sip
, tel
, etc.) addresses from spamming bots.
Address to cloak, e.g.
{{< cloakemail "[email protected]" >}}
or via named address
paramater:
{{< cloakemail address="[email protected]" >}}
Don't indicate other URI parameters, for instance to indicate an e-mail subject. For such feature, use instead optional query
parameter (see below).
protocol
to specify the protocol: {{< cloakemail address="[email protected]" protocol="xmpp" >}}
or {{< cloakemail address="+1 212 664-7665" protocol="tel" >}}
display
to display any text on the page instead of the address: {{< cloakemail address="[email protected]" display="Send us a mail!" >}}
class
to indicate CSS classes to use: {{< cloakemail address="[email protected]" class="vip company-a" >}}
query
to specify a e-mail subject or other URI parameters (URI query): {{< cloakemail address="[email protected]" query="subject=Message from contact form" >}}
. The query is never printed on the web page.All parameters can be combined.
Given address [email protected]
, the shortcode
<span class="cloaked-e-mail" data-user="eod.enaj" data-domain="moc.elpmaxe"></span>
in the web page.@
in-between. No link is available yet.<a href=...>
element.hugo-cloak-email
as a submodule to be able to get upstream changes later git submodule add https://github.com/martignoni/hugo-cloak-email.git themes/hugo-cloak-email
hugo-cloak-email
as the left-most element of the theme
list variable in your site's or theme's configuration file config.yaml
or config.toml
. Example, with config.yaml
:
theme: ["hugo-cloak-email", "my-theme"]
or, with config.toml
,
theme = ["hugo-cloak-email", "my-theme"]
{{< cloakemail "[email protected]" >}}
or
{{< cloakemail address="[email protected]" >}}
Copyright © 2019 onwards, Nicolas Martignoni [email protected].
Thanks to @mxmehl for ideas and explanations about other protocols and script fingerprinting.
This theme component was possible because of the work done by @danieka in this pull request.