When a Jekyll post or page's title or date changes, existing links to the site may break. For the security of our users, GitHub Pages does not support customer server configuration files such as .htaccess
or .conf
. However, using the Jekyll Redirect From plugin, you can automatically redirect visitors to the updated URL.
Setting up
To enable redirects, you must add the following line to your site's _config.yml file:
gems:
- jekyll-redirect-from
If you don't have a _config.yml file, you will need to create one in the root of your GitHub Pages repository. For more information, see Jekyll's official plugins documentation.
Usage
To redirect a page from /foo/
to another page, add the following to the top of the target page:
---
redirect_from: "/foo/"
---
Testing locally
To verify redirects locally:
- Add
jekyll-redirect-from
to your site's _config.yml file - Make sure you're using the latest version of the GitHub Pages Gem, which contains these dependencies and plugins.
For more information, see The Jekyll Redirect From Gem.