How to do redirects in Jekyll.

jekyll redirects websites

I am redoing some segments of my website – probably a bad idea – and wanted to put in place some redirects in case people have bookmarks or something like that. To my surprise, I get steady visitors to my multi-page tutorials.

This is super easy with a Jekyll plugin jekll-redirect-from!

Quick overview – read from the plugin authors for more detail though:

  • add the plugin to your _config.yml file
  • in the target file, i.e. where you want people to end up, put redirect_from: /ts/2018_07_28/ in the front matter.

Generate and you’re good to go. What happens is the plugin generates an HTML file that performs the redirect:

<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <link rel="canonical" href="http://localhost:4000/ts/2018/07/27/docker-tutorial-1/">
  <meta http-equiv="refresh" content="0; url=http://localhost:4000/ts/2018/07/27/docker-tutorial-1/">
  <meta name="robots" content="noindex">
  <a href="http://localhost:4000/ts/2018/07/27/docker-tutorial-1/">Click here if you are not redirected.</a>

which you can take a look at in the _site folder.

© Amy Tabb 2018 - 2023. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.