{% redirect %}

Use this tag to redirect to another page or URL. Note that this method of redirect is much slower than using built-in redirects.

Syntax

{% redirect newPage %}

newPage may resolve to a fully-qualified URL (including the leading "http://", "https://", or just "//"), a relative URL (starting with the leading "/"), an entity object with a valid default_page_url, or a Marketpath CMS page.

If the URL appears to be valid, the request response will be a "302 Found" http response pointing to the new location.

If the URL does NOT appear to be valid, an error page will be shown instead.

Examples

{% if user.guest %}
    {% redirect request.path | url_encode | prepend: "/log-in?r=" %}
{% endif %}
{% if page.restrictiontype.is_valid and page.restrictionpage.is_valid %}
    {% var restrictiontype = page.restrictiontype.value %}
    {% unless permissions[restrictiontype].allowed %}
        {% redirect page.restrictionpage %}
    {% endunless %}
{% endif %}

Developer Overview

Liquid Markup