Url

Url

{{ url }}

Field containing a URL.

Name Type Description
value String The URL as input into the field
url_type String The type of object selected as a URL. Options are 'None', 'Custom', 'Entity', 'Image', 'Document', 'Email', 'Tel', and 'Javascript'
reference_guid String The unique identifier for the selected object when url_type is either 'Entity', 'Image', or 'Document'
entity entity The entity object that this URL links to
image image The image object that this url links to
document document The document object that this url links to
field_id String The identifier for this field
label String The label for this field
output String The URL as input into the field. May include additional markup in the editor preview to make it easier to edit content

url_encode filter

Encode a string to be used in a URL.

url_encode: Boolean formdata

Examples

Use the url_encode and url_decode filters to encode strings for use in URLs, and to decode strings that have been url encoded.

Url Encoding and Decoding

Copy

url_encode

{{"liquid filter" | url_encode}}
{{"liquid filter" | url_encode:true}}

url_decode

{{"liquid%20filter" | url_decode}}
{{"liquid+filter" | url_decode}}
{{"liquid+filter" | url_decode:true}}

url_decode filter

Decode a url encoded string.

url_decode: Boolean formdata

Examples

Use the url_encode and url_decode filters to encode strings for use in URLs, and to decode strings that have been url encoded.

Url Encoding and Decoding

Copy

url_encode

{{"liquid filter" | url_encode}}
{{"liquid filter" | url_encode:true}}

url_decode

{{"liquid%20filter" | url_decode}}
{{"liquid+filter" | url_decode}}
{{"liquid+filter" | url_decode:true}}

base64_url_safe_decode filter

Decodes a string from a URL-safe base64 format. The difference between the base64 and URL-safe base64 formats is that the URL-safe format uses - and _ in place of + and /, which can cause problems when used in a URL.

base64_url_safe_decode

Examples

Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.

Encoding and decoding from base64

Copy

base64_encode

{{ '>>> do you want to stop?' | base64_encode }}

base64_decode

{{ 'Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/' | base64_decode }}

base64_url_safe_encode

{{ '>>> do you want to stop?' | base64_url_safe_encode }}

base64_url_safe_decode

{{ 'Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_' | base64_url_safe_decode }}

base64_url_safe_encode filter

Encodes a string to a URL-safe base64 format. The difference between the base64 and URL-safe base64 formats is that the URL-safe format uses - and _ in place of + and /, which can cause problems when used in a URL.

base64_url_safe_encode

Examples

Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.

Encoding and decoding from base64

Copy

base64_encode

{{ '>>> do you want to stop?' | base64_encode }}

base64_decode

{{ 'Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/' | base64_decode }}

base64_url_safe_encode

{{ '>>> do you want to stop?' | base64_url_safe_encode }}

base64_url_safe_decode

{{ 'Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_' | base64_url_safe_decode }}

{% set_canonical_url %}

Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

The current canonical URL is available at {{ automatic_markup.canonical_url }}

Examples

Use the url_encode and url_decode filters to encode strings for use in URLs, and to decode strings that have been url encoded.

Url Encoding and Decoding

Copy

url_encode

{{"liquid filter" | url_encode}}
{{"liquid filter" | url_encode:true}}

url_decode

{{"liquid%20filter" | url_decode}}
{{"liquid+filter" | url_decode}}
{{"liquid+filter" | url_decode:true}}

URL: www.domain.com/path/to/page?alpha=abc&beta=b&&emptyvariable&animals=cat&animals=dog&animals=fish

Copy
{{ request.query_params }} => alpha=abc&beta=b&&emptyvariable&animals=cat&animals=dog&animals=fish {{ request.query_params.count }} => 4 {{ request.query_params.length }} => 7 {{ request.query_params.alpha }} => abc {{ request.query_params.emptyvariable }} => {{ request.query_params['animals'] }} => cat,dog,fish {{ request.query_params[1] }} => beta=b {% if request.query_params has_key 'alpha' %}has alpha{% else %}no alpha{% endif %} => has alpha {% if request.query_params contains 'animals=cat' %}cat{% else %}no cat{% endif %} => cat {% for param in request.query_params %} --same as {% for param in request.query_params.by_index %} {% unless forloop.first %}, {% endunless %}{{param}} {% endfor %} => alpha=abc, beta=b, , emptyvariable, animals=cat, animals=dog, animals=fish {% for param in request.query_params.keys %} {% unless forloop.first %}; {% endunless %}{{param}}: {{request.query_params[param]}} {% endfor %} => alpha: abc; beta: b; emptyvariable: ; animals: cat,dog,fish

Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.

Encoding and decoding from base64

Copy

base64_encode

{{ '>>> do you want to stop?' | base64_encode }}

base64_decode

{{ 'Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/' | base64_decode }}

base64_url_safe_encode

{{ '>>> do you want to stop?' | base64_url_safe_encode }}

base64_url_safe_decode

{{ 'Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_' | base64_url_safe_decode }}

Redirect to requested page with login path appended

Copy
{% if user.guest %} {% redirect request.path | url_encode | prepend: "/log-in?r=" %} {% endif %}

Create Link with URL field

Copy
{% if entity.inspiration_url.is_valid %}


Inspired By {{ entity.inspiration_url }}

{% endif %}