Skip to content

Developers · Pages and Layouts

Developer redirects

Last updated 7 November 2026

Send visitors from one address to another, with a front-matter redirect or the redirect_to tag.

A redirect sends a visitor from one address to another. Use one when you move a page, retire an old address, or send people who are not signed in to a sign-in page. Insites gives you two ways: a redirect set on the page itself, and the redirect_to tag in Liquid for redirects that depend on a condition.

Redirect a whole page

Set redirect_to in the page's front matter. Every request to the slug is sent to the new address:

app/views/pages/old-page.liquid

---
slug: old-page
redirect_to: /new-page
redirect_code: 301
---
redirect_codeMeaning
301Moved permanently. Search engines move the old address to the new one
302Found, a temporary move. The default when redirect_code is blank
307A temporary move that keeps the request method

The schema accepts 301, 302 and 307 for redirect_code.

Redirect on a condition

Use the tag in the page body. It takes one value, and an optional status:

{%- if context.current_user == blank -%}
  {% redirect_to '/sign-in', status: 302 %}
{%- endif -%}

To redirect to an address with values in it, build the address first and pass the variable:

{% assign post_url = '/posts/' | append: context.params.id %}
{% redirect_to post_url %}

Redirects to other sites work too, for example {% redirect_to 'https://example.com/page' %}. For access control, an authorization policy with its own redirect_to is usually the better tool, because it runs before the page.

Note

These examples come from the GraphQL schema and the Logic Engine routing reference. The docs instance has no pages with a front-matter redirect, so none was run.

Common mistakes

  • Putting a filter after the value, such as {% redirect_to url | append: '/x' %}. The filter is dropped with no error. Assign first.
  • Redirecting to an address taken straight from a request parameter. That is an open redirect: check it is a path on your own site first.
  • Using 302 for a permanent move. Search engines keep the old address.