Redirects on GitHub Pages
GitHub Pages is available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.
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:
plugins:
- 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.