Skip to content

How to make a redirect

Jim Thoburn edited this page May 26, 2017 · 1 revision

Example file

Here’s an example redirect file: https://github.com/foodoasisla/site/blob/master/prototype.md

You can try it out by visiting this URL: https://foodoasis.la/prototype/

Steps

Here are some steps you can follow to make a new redirect…

  1. Create a new file with a name that matches the URL you want to redirect from. For example, a file named food.md could act as a redirect for foodoasis.la/food. You can place this file at the root of the website.

  2. Copy and paste this example code into your new file:

---
layout: default

title: Redirecting to Example Location

redirect: https://example.com
---

# Redirecting to Example Location…

[https://example.com](https://example.com)
  1. Change the “redirect” URL to the place where you want to redirect to.

  2. Update the page title and content with information about the redirect.

Background

Since the website is hosted on GitHub, redirects are done on the client side. When the site is generated, the “redirect” URL is translated into a refresh element…

<meta http-equiv="refresh" content="0; url=https://example.com" />

The title and content of the page are helpful to search engines and also provide a fallback for users–just in case the meta element doesn’t work.

Clone this wiki locally