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:
- Moving content to a new URL
- Consolidating multiple URLs into a single URL
- Sending visitors to a different website
- Preventing broken links
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:
- Redirecting an old blog post to a new blog post: If you have written a new blog post that covers the same topic as an old blog post, you can use a redirect to send visitors from the old blog post to the new blog post. This will help to keep your blog content up-to-date and ensure that visitors can always find the most accurate information.
- Redirecting a product page to a new product page: If you have discontinued a product, you can use a redirect to send visitors from the old product page to a new product page that sells a similar product. This will help to reduce the number of 404 errors on your website and provide visitors with a better user experience.
- Redirecting a category page to a new category page: If you have reorganized your website's categories, you can use redirects to send visitors from the old category pages to the new category pages. This will help to avoid 404 errors and ensure that visitors can still find the products or content they are looking for.
- Redirecting to an external website: You can also use redirects to send visitors to external websites. This can be useful if you are migrating your website to a new platform or if you are closing down your website altogether.