Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

jekyll-redirect-from

:twisted_rightwards_arrows: Seamlessly specify multiple redirections URLs for your pages and posts.

Subscribe to updates I use jekyll-redirect-from


Statistics on jekyll-redirect-from

Number of watchers on Github 377
Number of open issues 7
Average time to close an issue 2 months
Main language Ruby
Average time to merge a PR 9 days
Open pull requests 14+
Closed pull requests 12+
Last commit over 1 year ago
Repo Created almost 6 years ago
Repo Last Updated over 1 year ago
Size 190 KB
Organization / Authorjekyll
Latest Releasev0.13.0
Contributors13
Page Updated
Do you use jekyll-redirect-from? Leave a review!
View open issues (7)
View jekyll-redirect-from activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating jekyll-redirect-from for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

JekyllRedirectFrom

Give your Jekyll posts and pages multiple URLs.

When importing your posts and pages from, say, Tumblr, it's annoying and impractical to create new pages in the proper subdirectories so they, e.g. /post/123456789/my-slug-that-is-often-incompl, redirect to the new post URL.

Instead of dealing with maintaining those pages for redirection, let jekyll-redirect-from handle it for you.

Build Status

How it Works

Redirects are performed by serving an HTML file with an HTTP-REFRESH meta tag which points to your destination. No .htaccess file, nginx conf, xml file, or anything else will be generated. It simply creates HTML files.

Installation

Add this line to your application's Gemfile:

gem 'jekyll-redirect-from'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jekyll-redirect-from

Once it's installed into your evironment, add it to your _config.yml:

plugins:
  - jekyll-redirect-from

If you are using a Jekyll version less than 3.5.0, use the gems key instead of plugins.

If you're using Jekyll in safe mode to mimic GitHub Pages, make sure to add jekyll-redirect-from to your whitelist:

whitelist:
  - jekyll-redirect-from

Then run jekyll <cmd> --safe like normal.

Usage

The object of this gem is to allow an author to specify multiple URLs for a page, such that the alternative URLs redirect to the new Jekyll URL.

To use it, simply add the array to the YAML front-matter of your page or post:

title: My amazing post
redirect_from:
  - /post/123456789/
  - /post/123456789/my-amazing-post/

Redirects including a trailing slash will generate a corresponding subdirectory containing an index.html, while redirects without a trailing slash will generate a corresponding filename without an extension, and without a subdirectory.

For example...

redirect_from:
  - /post/123456789/my-amazing-post

...will generate the following page in the destination:

/post/123456789/my-amazing-post

While...

redirect_from:
  - /post/123456789/my-amazing-post/

...will generate the following page in the destination:

/post/123456789/my-amazing-post/index.html

These pages will contain an HTTP-REFRESH meta tag which redirect to your URL.

You can also specify just one url like this:

title: My other awesome post
redirect_from: /post/123456798/

Prefix

If site.url is set, its value, together with site.baseurl, is used as a prefix for the redirect url automatically. This is useful for scenarios where a site isn't available from the domain root, so the redirects point to the correct path. If site.url is not set, only site.baseurl is used, if set.

Note: If you are hosting your Jekyll site on GitHub Pages, and site.url is not set, the prefix is set to the pages domain name i.e. http://example.github.io/project or a custom CNAME.

Redirect To

Sometimes, you may want to redirect a site page to a totally different website. This plugin also supports that with the redirect_to key:

title: My amazing post
redirect_to:
  - http://www.github.com

If you have multiple redirect_tos set, only the first one will be respected.

Note: Using redirect_to or redirect_from with collections will only work with files which are output to HTML, such as .md, .textile, .html etc.

Customizing the redirect template

If you want to customize the redirect template, you can. Simply create a layout in your site's _layouts directory called redirect.html.

Your layout will get the following variables:

  • page.redirect.from - the relative path to the redirect page
  • page.redirect.to - the absolute URL (where available) to the target page

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
jekyll-redirect-from open issues Ask a question     (View All Issues)
  • almost 3 years Config option to set custom attributes on redirect links (data-proofer-ignore)
  • about 3 years Expose a list of generated redirects for testing tools
  • about 3 years Automatic redirect from underscores to hyphens in URLs
  • about 3 years Preserve fragment and query string in redirect
  • about 3 years Redirects from index.php to / go into infinite loop
  • about 3 years Support defining redirects in central _config.yml
  • over 3 years Redirect page is processed as Markdown
jekyll-redirect-from open pull requests (View All Pulls)
  • Ensure output extension is assigned
  • WIP: Allow custom layout for redirect page
  • Improve aesthetics of flash of unstyled content.
  • Default to site.url
  • Add <html> tag and language
  • use original destination path for Page construction
  • Ensure redirect_to links produce an HTML file.
  • Include absolute path in canonical url
  • Inherit Jekyll's rubocop config for consistency
  • Preserve search and hash in redirect
  • Test against same version of Ruby that GitHub Pages uses
  • Test against Ruby 2.5
  • Render liquid tags in redirect urls.
  • run javascript at first to avoid splash
jekyll-redirect-from questions on Stackoverflow (View All Questions)
  • Combination of jekyll-redirect-from and github-metadata gems throwing errors
  • Jekyll-Redirect-From Redirects Not Being Applied
jekyll-redirect-from list of languages used
jekyll-redirect-from latest release notes
v0.13.0 v0.13.0

Minor

  • Add no-index (#152)
  • normalize from metadata to ensure leading slash
  • create redirects.json file
  • HTML encode ellipsis

Development

  • Target Ruby 2.1
  • Test against GitHub Pages Ruby version (#132)
  • Fix tests for jekyll 3.5.x (#160)
  • Define path with dir (#161)
  • Fix Rubocop offenses (#165 )
  • Standardize scripts
v0.12.1

Development Fixes

  • Stop testing Ruby 1.9 (#133)

Minor Enhancements

  • Use send to monkey patch to support Ruby < 2.2.0 (#136)
  • set page.output to empty string instead of nil (#137)
v0.12.0

Major Enhancements

  • Use _layouts/redirect.html as the redirect template if present in the site source
  • Use Jekyll's absolute_url filter to generate canonical URLs (now respecting baseurl)
  • Rely more heavily on Jekyll's native Page, permalink, and extension handling logic

Minor Enhancements

  • redirect_to Pages should not have a layout. (#115)
  • Require Jekyll >= 3.3

Development Enhancements

  • Push redirect logic to the redirect page model (#131)
  • Add Rubocop and enforce Jekyll coding standards
  • Tests no longer build and write the entire site between each example
  • Removed all the is_*? and has_*? helpers from the generator
Other projects in Ruby