escape

Escapes a string by replacing HTML special characters with escape sequences. It doesn’t change strings that don’t have anything to escape.
{{ "Have you read 'James & the Giant Peach'?" | escape }}
Have you read 'James & the Giant Peach'?
{{ "Tetsuro Takara" | escape }}
Tetsuro Takara

escape_once

Escapes a string without changing existing escaped entities. It doesn’t change strings that don’t have anything to escape.
{{ "1 < 2 & 3" | escape_once }}
1 &lt; 2 &amp; 3
&#x7B;&#x7B; "{{"1 &lt; 2 &amp; 3" | escape}}" | escape_once }}
1 &lt; 2 &amp; 3

strip_html

Removes any HTML tags from a string.
{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}
Have you read Ulysses?

newline_to_br

Replaces every newline (\n) in a string with an HTML line break (“).
{% capture string_with_newlines %}
Hello
there
{% endcapture %}

{{ string_with_newlines | newline_to_br }}
<br/>Hello<br/>there<br/>

url_encode

Converts any URL-unsafe characters in a string into percent-encoded characters.
{{ "john@liquid.com" | url_encode }}
john%40liquid.com
{{ "Tetsuro Takara" | url_encode }}
Tetsuro+Takara

url_decode

Decodes a string that has been encoded as a URL.
{{ "%27Stop%21%27+said+Fred" | url_decode }}
'Stop!' said Fred

xml_escape

Escape some text for use in XML.
{{ "Have you read \'James & the Giant Peach\'?" | xml_escape }}
Have you read &#39;James &amp; the Giant Peach&#39;?

cgi_escape

CGI escape a string for use in a URL. Replaces any special characters with appropriate %XX replacements. CGI escape normally replaces a space with a plus + sign.
{{ "foo, bar; baz?" | cgi_escape }}
foo%2C+bar%3B+baz%3F

uri_escape

Percent encodes any special characters in a URI. URI escape normally replaces a space with %20. Reserved characters will not be escaped.
{{ "https://example.com/?q=foo, \bar?" | uri_escape }}
https://example.com/?q=foo,%20%5Cbar?

slugify

Convert a string into a lowercase URL “slug”. The slugify filter accepts 2 options:
  1. mode: string. The default is "default". They are as follows (with what they filter):
  • "none": no characters
  • "raw": spaces
  • "default": spaces and non-alphanumeric characters
  • "pretty": spaces and non-alphanumeric characters except for ._~!$&'()+,;=@
  • "ascii": spaces, non-alphanumeric, and non-ASCII characters
  • "latin": like default, except Latin characters are first transliterated (e.g. àèïòü to aeiou).
  1. case: boolean. The default is false. The original case of slug will be retained if set to true.
{{ "The _config.yml file" | slugify }}
the-config-yml-file
{{ "The _config.yml file" | slugify: "pretty" }}
the-_config.yml-file
{{ "The _cönfig.yml file" | slugify: "ascii" }}
the-c-nfig-yml-file
{{ "The cönfig.yml file" | slugify: "latin" }}
the-config-yml-file
{{ "The cönfig.yml file" | slugify: "latin", true }}
The-config-yml-file