Hugo Encoder Module

Encode text to protect email address and telephone number from spam bots.

Module
github.com/hugomods/encoder
GitHub Stars Used By Used By Used By Used By

Shortcodes

encode Shortcode

encode Shortcode Syntax

1{{< encode [text] >}}

encode Shortcode Parameters

text
PositionNameTypeRequiredDefaultSince
#0textstring--

The text to be encoded.

Encode Plain Email
1{{< encode "user@example.org" >}}
[email protected]
Encode Plain Telephone Number
1{{< encode "123-12345678" >}}
123-12345678
1{{< encode-link [protocol] [target] [text] >}}
protocol
PositionNameTypeRequiredDefaultSince
#0protocolstring--

The link protocol, e.g. mailto, tel.

target
PositionNameTypeRequiredDefaultSince
#1targetstring--

The target of link, such as email address ([email protected]), telephone number (123-12345678).

text
PositionNameTypeRequiredDefaultSince
#0textstring---

The link text, default to the target.

*
PositionNameTypeRequiredDefaultSince
-*string---

Others parameter will be treated as the link attributes, such as class, rel.

1{{< encode-link "mailto" "user@example.org" >}}
2
3{{< encode-link protocol="mailto" target="[email protected]" text="Send me an email." >}}
4
5{{< encode-link protocol="mailto" target="[email protected]" text="Send me an email." class="text-success" >}}
[email protected] Send me an email. Send me an email.
1{{< encode-link "tel" "123-1234567" >}}
2
3{{< encode-link protocol="tel" target="123-12345678" text="Call me." >}}
4
5{{< encode-link protocol="tel" target="123-12345678" text="Call me." class="text-success" >}}
123-1234567 Call me. Call me.

encode-email Shortcode

A shorthand of encode-link for email address that without requirements of specifying the protocol parameter.

1{{< encode-email [target] [text] >}}

encode-tel Shortcode

A shorthand of encode-link for telephone number that without requirements of specifying the protocol parameter.

1{{< encode-tel [target] [text] >}}