Redirects

Timothy Kempf edited this page Feb 28, 2014 · 12 revisions

Redirects are special routes that redirect to another URL. These URLs can be local or on another website altogether. Generally, these are used when pages move from one URL to another, or for temporary promotional purposes.

=====

Creating a Redirect

Redirects can easily be defined using the redirects.json file located in the site's base directory. This file simply contains an array of objects composed of redirect options. Here's a list of possible redirect options:

option type purpose
from string The route you want to redirect from. This option is required. Ex: /search
to string The URL you want to redirect to. This option is required. Ex: http://www.google.com
permanent boolean Whether or not the redirect is permanent. If true, the redirect will be set to 301 Moved Permanently, if false (or left blank) the redirect will be set to 302 Found.
start string (date) When the redirect goes into effect. Should be in YYYY-MM-DD HH:MM:SS -0000 format.
end string (date) When the redirect stops. Should be in YYYY-MM-DD HH:MM:SS -0000 format.

Here's an example redirects.json:

[{
    "from": "/redirect1",
    "to": "/"
}, {
    "from": "/redirect2",
    "to": "/",
    "start": "2000-1-1 00:00:00 -0800"
}, {
    "from": "/redirect3",
    "to": "/",
    "start": "2000-1-1 00:00:00 -0800",
    "end": "2014-1-1 00:00:00 -0800"
}, {
    "from": "/redirect4",
    "to": "/",
    "end": "2000-1-1 00:00:00 -0800"
}, {
    "from": "/redirect5",
    "to": "/",
    "permanent": true
}]

NEXT: Preprocessors

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.