Well, it happens. We move a page or a site to make things work better. But what about the people trying to get to the old page? We don’t want to just leave people hanging. They tend to not like that.

Now, we can just use 301 rewrite rules in htaccess, or use nginx redirects. But if we have github or somewhere where we can’t do that, what then?

Well, the next best thing is to use the jekyll-redirect-from to redirect pages. It’s pretty easy.

Note: Many people don’t like MetaRefresh which is the method used here to redirect. See the note at the bottom of the page

Install

Add this to your Gemfile:

gem 'jekyll-redirect-from'

Then update your bundle:

bundle

Add the plugin jekyll-redirect-from to your _config.yaml file, making sure to add it to the gems or whitelist areas if you already have them:

gems:
  - jekyll-redirect-from

# mimic GitHub Pages with --safe
whitelist:
  - jekyll-redirect-from

Then run your jekyll like you always do:

jekyll <cmd> --safe

Redirect internally

To use it, just add this to your file’s frontmatter:

title: Your Post
aliases:
  - /old/page/
  - /old2/page2

That will create a /old/page/index.html and an /old2/page2 page that redirects to the Your Post page.

Redirect to Other Sites

To redirect to other pages, use:

title: Your Post2
redirect_to:
  - https://www.supertechcrew.com/

You’ll notice the redirect_to entry that tells jekyll to create a page for Your Post2 that will redirect to https://www.supertechcrew.com/.

Plain and simple.

Warning About MetaRefresh

Many places on the internet say you shouldn’t use MetaRefreshes anymore. And they have valid reasons. This method uses MetaRefresh because there is no other way to do so on GitHub.

If you have your own server, I’d recommend using a Rewrite rule or something else like that to redirect pages transparently without showing the user a redirect page. It’s cleaner, but requires your to edit server config files or htaccess files.