DEV Community

Will Vincent
Will Vincent

Posted on • Originally published at wsvincent.com

1 1

Jekyll 301 Redirects on Netlify

My personal site is built with Jekyll and hosted on Netlify. Recently I needed to implement redirects for my posts on installing Python on Mac, Windows, or Chromebook which now live over at installpython3.com.

Per the Netlify docs, there are two methods available: create a _redirects file or a netlify.toml file. The former is simpler and worked just fine in my case where I wanted a 301 redirect, the default, since the move was permanent and SEO would be maintained as much as possible.

There are two steps required: create the _redirects file and then add it to the existing _config.yml file.

Step 1: Create _redirects file

This involved creating a file called _redirects in my project root that contained the URL of a post on this site and then the redirect post it should be sent to separated by whitespace. So for my 3 posts, here's what the file looks like.

install-python3-mac/ https://installpython3.com/mac/
install-python3-windows/ https://installpython3.com/windows/
install-python3-chromebook/ https://installpython3.com/chromebook/
Enter fullscreen mode Exit fullscreen mode

Step 2

This one is easy to miss! The existing _config.yml file used by Jekyll needs to be updated to include _redirects. So at the bottom of _config.yml add the following line:

include: [_redirects]
Enter fullscreen mode Exit fullscreen mode

And that's it! Deploy your site to Netlify per usual and then check that the link redirects properly. There are a number of tools to do this but I found this one worked well.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more