Open Sitez Documentation

Documentation main page

 

How to create redirects in Open Sitez

Redirects are a way to redirect visitors from one URL to another. They can be used for a variety of purposes, such as:

There are two ways to create redirects in Open Sitez:

1. Using the type: redirect setting in a route

To create a redirect using the type: redirect setting, simply create a route with the type: redirect setting and specify the URL that you want to redirect visitors to. For example, the following YAML will create a redirect from the /home URL to the / URL:

routes:
  home:
    type: redirect
    url: /

2. Using the global.redirects setting

To create redirects using the global.redirects setting, simply create a global section in your YAML file and add a redirects setting to it. The redirects setting should be a list of redirects, with each redirect being in the following format:

url: /old-url/
redirect: /new-url/

For example, the following YAML will create two redirects:

global:
  redirects:
    home: /
    example: http://example.com/

This YAML will create a redirect from the /home URL to the / URL and a redirect from the /example URL to the http://example.com/ URL.

Which way to use depends on your personal preference. The first way is more explicit, while the second way is more compact. If you are only creating a few redirects, then the first way may be more readable and easier to understand. If you are creating a large number of redirects, then the second way may be more efficient.

Here are some examples of how to use redirects in Open Sitez: