Hugo Encoder Module

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

Modulegithub.com/hugomods/encoder
StatsGitHub Stars Used By Used By Used By Used By

Shortcodes

encode Shortcode

encode Shortcode Syntax

1{{< encode [text] >}}

encode Shortcode Parameters

text
PositionNameTypeRequiredDefaultSinceExample
#0textstring---

The text to be encoded.

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

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

target
PositionNameTypeRequiredDefaultSinceExample
#1targetstring---

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

text
PositionNameTypeRequiredDefaultSinceExample
#0textstring----

The link text, default to the target.

*
PositionNameTypeRequiredDefaultSinceExample
-*string----

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

Source
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" >}}
Source
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" >}}

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] >}}