Code Monkey home page Code Monkey logo

jekyll-redirect-from's Introduction

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 environment, 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 objective 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

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

Configuration

You can configure this plugin in _config.yml by adding to the redirect_from key.

Disabling redirects.json

By default, a file called redirects.json, which can be used for automated testing or to implement server-side redirects, will be included in the output. To exclude it from the output, set the json key to false:

redirect_from:
  json: false

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's People

Contributors

akoeplinger avatar ashmaroli avatar axelheer avatar benbalter avatar crunch09 avatar dentarg avatar dirtyf avatar dmalan avatar donavanwells avatar eksperimental avatar gjtorikian avatar jekyllbot avatar jszwedko avatar kinow avatar lemonez avatar lukemcgregor avatar mathiasbynens avatar mnuessler avatar ndarville avatar newfuture avatar parkr avatar pathawks avatar satyanash avatar toolness avatar wasabifan avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jekyll-redirect-from's Issues

wildcard redirection

Would be great to have this ability, i.e.

redirect_from:
  - /tag/*

Is this possible by url handling engine?

Auto-generate short URL's?

We were chatting in jekyll/jekyll-help#6 about the best way to get short URL's setup and I thought it would be pretty darn cool to do that automatically here. That said, it may be stupid because adding in a line to your redirect_from key for an auto-generated short URL would be just as easy as making a semantic short URL that's more related to your post/page. Thoughts?

Subtle typo causes silent failure

I came across this issue by accident.

In my YAML front matter, I accidentally used redirect-from: instead of redirect_from: on a couple of posts. Instead of simply ignoring the incorrect form or sending an error to the terminal, jekyll-redirect-from silently allows the site to be built but without inserting redirects.

Generating extension-less files instead of directories with and index

I'm using jekyll-redirect-from on this post on my blog, but it's not properly generating a new directory and redirect index file, it's only generating part of the new directory structure, with just files inside.

Should be generating:

/_site/writing/2013/making-gravlax-part-2/index.html

...but is instead generating

$ ls _site/writing/2013/
making-gravlax-part-1 making-gravlax-part-2

Does not work for collections

Do generators not get collections? Had a site that had pages, moved them over to collections, and now redirects aren't being created.

Add support for a base URL configuration option for redirection

Redirects currently don't support project pages very well, as you need to put the project page path in the paths you specify under the redirect_from heading. It'd be nice to offer a configuration option (like redirect_prefix) which added a prefix to every redirect URI.

See the conversation in #15 for more.

optional favicon or let user set their own redirect template

Hi, I' m checking a website with html-proofer, and if I choose to check the docs with the check_favicon option, it will complain about the redirects generated by this plugin.
I think it will be helpful, and since html-proofer is being promoted by jekyll itself to be used in continous integration I think it' s an opt-in option that we should consider..

or even more ambitous and less code to maintain... should we let user replace the default template and let them load the template they want. this way people can choose the redirection time, set favicon, and have absolute control over what' s being output

Redirection loop

When using multiple redirect_from values, if one of the values generates the same "default" URL as configured in the _config.yml file (under permalink), you end up with an endless loop of redirections.

Redirect to extensionless url

I would like to get

/page.html -- is the file created by Jekyll
/page -- is how I link to the file and GitHub Pages serves the page.html page
/page.php -- this page gets redirected to /page

I am attempting to get this with:

Use redirect_from: /page.php.html on the page (GitHub will serve this when accessing /page.php)
Use standard settings for permalink

The result I get is:

/page.html -- is created
/page -- is accessible
/page.php -- redirects to page.html

Please advise if it possible to get the desired behavior.

Jekyll 3 starting to download file instead of redirecting

permalink: /contacts/
redirect_from:
 - /contact-information

When I passed to /contact-information browser was not redirecting as expected, but downloaded file with correct html

<!DOCTYPE html>
<meta charset=utf-8>
<title>Redirecting...</title>
<link rel=canonical href="/contacts/">
<meta http-equiv=refresh content="0; url=/contacts/">
<h1>Redirecting...</h1>
<a href="/contacts/">Click here if you are not redirected.</a>
<script>location='/contacts/'</script>

Wonky problem with collections?

I hate to open an issue like this, but I seem to be having trouble generating redirect pages for collections.

When I run this test suite locally, here is what I see:

All examples were filtered out; ignoring {:focus=>true}
............F...............

Failures:

  1) JekyllRedirectFrom::Redirector knows if a document is requesting a redirect page
     Failure/Error: expect(redirector.has_alt_urls?(doc_to_redirect)).to be_truthy
       expected: truthy value
            got: false
     # ./spec/jekyll_redirect_from/redirector_spec.rb:17:in `block (2 levels) in <top (required)>'

Finished in 0.9015 seconds (files took 0.27304 seconds to load)
28 examples, 1 failure

Failed examples:

rspec ./spec/jekyll_redirect_from/redirector_spec.rb:16 # JekyllRedirectFrom::Redirector knows if a document is requesting a redirect page

bundle show jekyll tells me that I'm on 2.3.0.

When I use 0.6.1 of this gem, my collection redirect pages are generated, but their contents are totally blank.

It sounds like there's something misconfigured on my system, but I can't imagine at all what that might be.

cannot load such file -- jekyll/post (LoadError)

I am getting this, while adding this gem to a jekyll (3.0.0) project:

/whatever/bundle/ruby/2.1.0/gems/jekyll-redirect-from-0.8.0/lib/jekyll-redirect-from/redirector.rb:41:in `is_dynamic_document?': cannot load such file -- jekyll/post (LoadError)
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-redirect-from-0.8.0/lib/jekyll-redirect-from/redirector.rb:47:in `has_alt_urls?'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-redirect-from-0.8.0/lib/jekyll-redirect-from/redirector.rb:14:in `block in generate_alt_urls'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/collection.rb:37:in `each'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/collection.rb:37:in `public_send'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/collection.rb:37:in `method_missing'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-redirect-from-0.8.0/lib/jekyll-redirect-from/redirector.rb:13:in `generate_alt_urls'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-redirect-from-0.8.0/lib/jekyll-redirect-from/redirector.rb:7:in `generate'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:154:in `block in generate'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:153:in `each'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:153:in `generate'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:58:in `process'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/command.rb:28:in `process_site'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:60:in `build'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:35:in `process'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /whatever/bundle/ruby/2.1.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /whatever/bundle/ruby/2.1.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /whatever/bundle/ruby/2.1.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /whatever/bundle/ruby/2.1.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /whatever/bundle/ruby/2.1.0/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /whatever/bundle/ruby/2.1.0/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /whatever/bundle/ruby/2.1.0/gems/jekyll-3.0.0/bin/jekyll:17:in `<top (required)>'
    from /home/csillag/kapisztran/orasite/admin/vendor/bundle/bin/jekyll:16:in `load'
    from /home/csillag/kapisztran/orasite/admin/vendor/bundle/bin/jekyll:16:in `<main>'

I haven't defined any redirects yet; I have only added the gem to _config.yml.
What am I missing?

Thanks.

site.github.url may cause builds to fail—and is undocumented

#26 added site.github.url as a configuration option for setting redirect prefixes, but that option will conflict with any other value of github in _config.yml (example). Shouldn't we handle an existing site.github value—without a corresponding site.github.url value—a bit more gracefully? At the very least, we should really document this behavior—I'm pretty sure that it's going to cause problems for anyone who isn't actively watching pull requests on this repository.

@akoeplinger @parkr @benbalter Could I get your 👀 on this?

Redirecting to github.com/<my user> instead of my domain?

Hey

Probably I didn't understand this prefix configuration well. But I couldn't make the redirect to redirect to my domain, it's redirecting to github.com instead.

I would like to redirect http://www.pablocantero.com/blog/2015/03/14/sidekiq-(redis)-vs-shoryuken-(aws-sqs)/ to http://www.pablocantero.com/blog/2015/03/14/sidekiq-redis-vs-shoryuken-aws-sqs/ (the only one difference is the parenthesis)

So in order to do that I added the redirect_from:

# _posts/2015-03-14-sidekiq-redis-vs-shoryuken-aws-sqs.md
layout: post
title: Sidekiq (Redis) vs Shoryuken (AWS SQS)
redirect_from:
  - /blog/2015/03/14/sidekiq-(redis)-vs-shoryuken-(aws-sqs)/

The redirect is def redirecting, but it's redirecting to https://github.com/phstc/blog/2015/03/14/sidekiq-redis-vs-shoryuken-aws-sqs (which does not exist) instead of http://www.pablocantero.com/blog/2015/03/14/sidekiq-redis-vs-shoryuken-aws-sqs/.

In my _config.yml I have

url: http://www.pablocantero.com/
baseurl: '/'

Any thoughts?

Error: undefined method `each' for "jekyll-redirect-from":String

Hi,

After a recent software update, jekyll-redirect-from seems to be causing an error which prevents a site from building:

$ ruby --version
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
$ gem --version
2.5.0
$ jekyll --version
jekyll 3.0.1
$ jekyll build
Configuration file: /home/user/repo/qubesos.github.io/_config.yml
jekyll 3.0.1 | Error:  undefined method `each' for "jekyll-redirect-from":String

And here it is with --trace:

$ jekyll build --trace
Configuration file: /home/user/repo/qubesos.github.io/_config.yml
/home/user/.gem/ruby/gems/jekyll-3.0.1/lib/jekyll/plugin_manager.rb:27:in `require_gems': undefined method `each' for "jekyll-redirect-from":String (NoMethodError)
    from /home/user/.gem/ruby/gems/jekyll-3.0.1/lib/jekyll/plugin_manager.rb:19:in `conscientious_require'
    from /home/user/.gem/ruby/gems/jekyll-3.0.1/lib/jekyll/site.rb:97:in `setup'
    from /home/user/.gem/ruby/gems/jekyll-3.0.1/lib/jekyll/site.rb:49:in `initialize'
    from /home/user/.gem/ruby/gems/jekyll-3.0.1/lib/jekyll/commands/build.rb:30:in `new'
    from /home/user/.gem/ruby/gems/jekyll-3.0.1/lib/jekyll/commands/build.rb:30:in `process'
    from /home/user/.gem/ruby/gems/jekyll-3.0.1/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /home/user/.gem/ruby/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /home/user/.gem/ruby/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /home/user/.gem/ruby/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /home/user/.gem/ruby/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /home/user/.gem/ruby/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /home/user/.gem/ruby/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /home/user/.gem/ruby/gems/jekyll-3.0.1/bin/jekyll:17:in `<top (required)>'
    from /usr/local/bin/jekyll:23:in `load'
    from /usr/local/bin/jekyll:23:in `<main>'

Any ideas? Am I missing something here?

Be able to control prefix even if on GitHub Pages

If I read the source correctly, you always prefer site.github.url if it's set.

Would it make sense to introduce another variable to be used, even if site.github.url is set?

We use GitHub Pages, but we don't use the CNAME file, because we have our own proxy and cache before GitHub Pages.

Redirect other assets?

I am in the process of migrating a WordPress blog to GitHub Pages, and I plan to change the directory structure of my uploaded files. But I want to keep any external links redirecting to the new location. Since an image obviously doesn't have a front matter header, is this possible? If so, how do I set it up?

Thanks.

Is index.html really needed in the redirected url?

My site uses 'pretty' URLs, so no index.html appears in the address bar.

After adding a redirect, I noticed that the address bar shows .../blog/index.html, which is functional, but not consistent with the rest of the site.

Is there any way to get rid of the index.html in redirects?

Redirect Page Not Functioning

While all of my redirects are currently generating pages, those pages don't seem to be functioning properly. Instead, I'm just shown a raw html page, like so:

http://d.pr/ISQI

I'm sure I'm missing something obvious, but any help would be appreciated.

Update: I see this is related to the trailing slash issue as already discussed here. This does seem like a bug to me, but I suppose you can close this issue.

Redirect with hash or query params

I'd like to be able to redirect to the given page with a hash and/or query parameters appended to the page's path. Is that possible or desirable to add?

Requirements and how it works should be described.

How redirects are performed?
Does it generate .htaccess for Apache? NginX conf?
It site is hosted on S3, does it generate XML with redirect rules?
Or it requires some server scripting? (So it will not works on static sites hostings?)

README should include answers.

Browser downloads content of generated redirect file instead of redirecting

I have redirect_from: /originsin the frontmatter of the page generating http://kortina.net/essays/origins-of-venmo/ but when I go to http://kortina.net/origins, Chrome downloads a file with these contents instead of redirecting:

  <!DOCTYPE html>
  <meta charset=utf-8>
  <title>Redirecting...</title>
  <link rel=canonical href="/essays/origins-of-venmo">
  <meta http-equiv=refresh content="0; url=/essays/origins-of-venmo">
  <h1>Redirecting...</h1>
  <a href="/essays/origins-of-venmo">Click here if you are not redirected.</a>
  <script>location='/essays/origins-of-venmo'</script>

I am hosting on GitHub pages. It appears the page is being generated correctly--is it just not being served correctly perhaps?

Broken on Jekyll3: Collection#each should be called on the #docs array directly

Getting the following on Jekyll 3.0.0

       Deprecation: Collection#each should be called on the #docs array directly.
                    Called by /home/will/.bundler/ruby/2.1.0/jekyll-redirect-from-0bfa97b3f6f2/lib/jekyll-redirect-from/redirector.rb:13:in `generate_alt_urls'.
/home/will/.bundler/ruby/2.1.0/jekyll-redirect-from-0bfa97b3f6f2/lib/jekyll-redirect-from/redirector.rb:41:in `is_dynamic_document?': cannot load such file -- jekyll/post (LoadError)
    from /home/will/.bundler/ruby/2.1.0/jekyll-redirect-from-0bfa97b3f6f2/lib/jekyll-redirect-from/redirector.rb:47:in `has_alt_urls?'
    from /home/will/.bundler/ruby/2.1.0/jekyll-redirect-from-0bfa97b3f6f2/lib/jekyll-redirect-from/redirector.rb:14:in `block in generate_alt_urls'
    from /home/will/.bundler/ruby/2.1.0/jekyll-redirect-from-0bfa97b3f6f2/lib/jekyll-redirect-from/redirector.rb:13:in `each'
    from /home/will/.bundler/ruby/2.1.0/jekyll-redirect-from-0bfa97b3f6f2/lib/jekyll-redirect-from/redirector.rb:13:in `generate_alt_urls'
    from /home/will/.bundler/ruby/2.1.0/jekyll-redirect-from-0bfa97b3f6f2/lib/jekyll-redirect-from/redirector.rb:8:in `generate'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:154:in `block in generate'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:153:in `each'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:153:in `generate'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:58:in `process'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/command.rb:28:in `process_site'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:60:in `build'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:35:in `process'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /var/lib/gems/2.1.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /var/lib/gems/2.1.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /var/lib/gems/2.1.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /var/lib/gems/2.1.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /var/lib/gems/2.1.0/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /var/lib/gems/2.1.0/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /var/lib/gems/2.1.0/gems/jekyll-3.0.0/bin/jekyll:17:in `<top (required)>'
    from /usr/local/bin/jekyll:23:in `load'
    from /usr/local/bin/jekyll:23:in `<main>'

Redirects from a .html file aren't generated

Hi all,

I'm moving to Jekyll from Blogger (blargh) and this plugin seems to be exactly what I need -- thanks!

Blogger specifies exact html files for my posts, e.g. http://www.seankilleen.com/2012/06/how-to-remove-table-formatting-in-excel.html

The following works: redirect_from: "/2012/06/how-to-remove-table-formatting-in-excel/"

But my use case is: redirect_from: "/2012/06/how-to-remove-table-formatting-in-excel.html"

This does not seem to generate an HTML file with that exact name.

Am I missing something? I couldn't find anything in the docs about pages that require the actual .html extension.

If this isn't something that the plugin currently supports, let me know and I can attempt to dig in and contribute. Thanks!

when url is missing backslash, correct redirect is not generated

I noticed that when specifying the URL to redirect from, the trailing backslash must be included or else jekyll-redirect-from fails to produce the correct redirect.

For example...

redirect_from: /some-url-to-redirect-from/

...works as expected, producing the correct subdirectory with an index.html. However...

redirect_from: /some-url-to-redirect-from

Does not produce /some-url-to-redirect-from/index.html but instead productes /some-url-to-redirect-from where it is a file with that name, instead of a directory with an index file.

Personally, I'm okay with that behavior, but think it should at least be specified in the README. However, if it's not too much work, or if you don't think it's problematic from an architecture standpoint, I'd say it might be nice to make both work as expected (i.e. any url created without a file extension should convert to a corresponding directory path with an index.html inside).

Customize HTML of redirect-page

It would be nice to be able to customize the HTML-code of the redirect-page. Because this page is visible while the browser is redirecting, it would look better if custom styling and messages could be displayed. It would also allow us to not redirect immediately, but to wait 1 or more seconds.

Suggestion: if the folder _layouts contains a file _redirect.html, use this file as the template.

Redirect issues with case insensitivity

This relates to jekyll/jekyll#3035.

On my site, the download page has the following front matter:


---
title: Downloads page
permalink: /download/
redirect_from: /Download/

---

The redirect is there to not break existing links from before the site was on Jekyll.

This works fine for me locally on Linux and when the site is hosted on GitHub Pages, but recently a user on Mac OSX told me he got into a redirect loop when locally serving the site. Turns out, as HFS+ is case insensitive by default the redirect page actually overrode the "real" page and essentially redirected to itself.

I know there might not be a good solution for that problem, but ideally it'd prefer the "real" page and just ignore the redirect instead of overwriting the file.

When is the plugin running?

I am trying to inject redirect_from properties during the build time, via a hook plugin.

When I use the pages pre-render hook, the redirect-from plugin does not seem to pickup the property.

Using post_init does not let me edit the page's properties.

Any ideas?

redirect from tries to acces front matter on static files

Investigating on this stackoverflow question I've found that redirect from tries to acces front matter on static files.

Reproduce :

  • new jekyll site (2.4)
  • a collection with static files like .js or .css
  • jekyll-redirect
  • jekyll build

Error : /var/lib/gems/1.9.1/gems/jekyll-redirect-from-0.6.2/lib/jekyll-redirect-from/redirector.rb:38:inhas_alt_urls?': undefined method data' for #<Jekyll::StaticFile:0x00000001baa4e0> (NoMethodError)

The Redirector:generate method at generate_alt_urls(site, site.docs_to_write) receive both collection files + static files, then method Redirector:has_alt_urls tries to access the unexisting method on statik file.

This is not reproduced in gh-page configuration as the generate_alt_urls(site, site.docs_to_write) doesn't exist.

Using variables or liquid in the redirect_from value

Can I make the redirect_from value include variables such as {{page.url}} or more complex values?

I have hundreds of pages that changed url structure and need a way to quickly map all of them to the new url...

Redirects shouldn't use binary mime-type

I'm observing a mime-type of application/octet-stream both locally (with github-pages installed) and on Github Pages.

Right now, I'm redirecting index.md at https://github.com/konklone/congress/blob/gh-pages/index.md to/not-index` as a test, and visiting:

http://konklone.io/congress/not-index

downloads the file as not-index. Curling yields:

$ curl --head http://konklone.io/congress/not-index
HTTP/1.1 200 OK
Server: GitHub.com
Date: Mon, 17 Mar 2014 16:43:09 GMT
Last-Modified: Mon, 17 Mar 2014 16:34:15 GMT
Expires: Mon, 17 Mar 2014 16:53:09 GMT
Cache-Control: max-age=600
Vary: Accept-Encoding
Accept-Ranges: bytes
Content-Type: application/octet-stream
Content-Length: 540

It seems like this shouldn't return a 200, either.

Redirect wildcard

This is my code from _config.yml

gems:
  - jekyll-redirect-from
redirect_from:
  - /*
  - /

with the intention of redirecting all requests to the index page. However, this is not working. Can someone please tell me the fix for this?

Add specs

There's no reason we should live without tests. Add them!

Generated link is wrong when baseurl option is used

I use the baseurl option of Jekyll: jekyll serve --baseurl=/test

Given this YAML front matter...


---
permalink: /subdir/About/
redirect_from: /About/

---

...I would have expected it to work, however the generated redirect points to /subdir/About/ instead of /test/subdir/About/ so the page is not found.

Generate 301/302 redirects

This is what a redirect from /foo to /bar looks like at the moment:

$ curl -D - 'http://localhost:4000/foo'
HTTP/1.1 200 OK
Etag: 8d25ba-14e-543e9642
Content-Type: application/octet-stream
Content-Length: 334
Last-Modified: Wed, 15 Oct 2014 15:44:02 GMT
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08)
Date: Wed, 15 Oct 2014 15:45:12 GMT
Connection: Keep-Alive

      <!DOCTYPE html>
      <meta charset=utf-8>
      <title>Redirecting...</title>
      <link rel=canonical href="/bar">
      <meta http-equiv=refresh content="0; url=/bar">
      <h1>Redirecting...</h1>
      <a href="/bar">Click here if you are not redirected.</a>
      <script>location='/bar'</script>

It would be better if this returned "301 Moved Permanently" or "302 Found" with an appropriate Location header, so that clients other than web browsers would know how to follow the redirect.

Can I use a redirection using the url pattern?

hello,
I'm making a landing page that supports the localization.
So, my expect result is :

http://domain.com/fr-FR
http://domain.com/fr_FR
http://domain.com/fr
http://domain.com/fr-US

And yes, they must redirect to same url.
My question is : Can I write as below (or use any patterns)?

redirect_from:
  - /fr*

Instead of

redirect_from:
  - /fr-FR
  - /fr-CA
  - /fr-US

Jekyll 2.0 conflict

This goes for https://github.com/jekyll/jekyll-mentions and https://github.com/jekyll/jemoji also.

❯ jekyll serve --watch
Configuration file: /Users/kevinsuttle/Code/kevinsuttle.github.io/_config.yml
/Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/specification.rb:2064:in `raise_if_conflicts': Unable to activate jekyll-redirect-from-0.3.1, because jekyll-2.0.0.alpha.3 conflicts with jekyll (~> 1.4) (Gem::LoadError)
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/specification.rb:1262:in `activate'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems.rb:196:in `rescue in try_activate'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems.rb:193:in `try_activate'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/plugin_manager.rb:28:in `block in require_gems'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/plugin_manager.rb:26:in `each'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/plugin_manager.rb:26:in `require_gems'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/plugin_manager.rb:19:in `conscientious_require'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/site.rb:70:in `setup'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/site.rb:33:in `initialize'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/commands/build.rb:26:in `new'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/commands/build.rb:26:in `process'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/lib/jekyll/commands/serve.rb:23:in `block (2 levels) in init_with_program'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mercenary-0.3.2/lib/mercenary/command.rb:220:in `call'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mercenary-0.3.2/lib/mercenary/command.rb:220:in `block in execute'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mercenary-0.3.2/lib/mercenary/command.rb:220:in `each'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mercenary-0.3.2/lib/mercenary/command.rb:220:in `execute'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mercenary-0.3.2/lib/mercenary/program.rb:35:in `go'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mercenary-0.3.2/lib/mercenary.rb:22:in `program'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/jekyll-2.0.0.alpha.3/bin/jekyll:18:in `<top (required)>'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/bin/jekyll:23:in `load'
    from /Users/kevinsuttle/.rbenv/versions/2.1.1/bin/jekyll:23:in `<main>'

_config.yml

name: Kevin Suttle
tagline: Designer. Developer. Writer. Presenter.
permalink: /posts/:title
markdown: kramdown
kramdown:
    input: GFM
    use_coderay: true
exclude: ["CNAME", "README.md", "node_modules", "bower_components/", "gulpfile.js", "package.json", "config.codekit"]
gems:
  - jekyll-redirect-from
  - jemoji
  - jekyll-mentions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.