Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect with hash or query params #28

Closed
ssorallen opened this issue Jun 5, 2014 · 6 comments
Closed

Redirect with hash or query params #28

ssorallen opened this issue Jun 5, 2014 · 6 comments

Comments

@ssorallen
Copy link

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?

@danvk
Copy link

danvk commented Oct 15, 2014

It would be tremendously useful to be able to redirect based on URL parameters. See this Stack Overflow question.

@parkr
Copy link
Member

parkr commented Oct 15, 2014

I think you both might be talking about different things.

@ssorallen
Copy link
Author

@parkr Yes I think you are right. I was asking to append a hash or query parameter to the redirect URL. For example:

VISIT http://google.com/outdated-page
REDIRECT_TO http://google.com/new-page?from=outdated-page

or

VISIT http://google.com/oudated-page
REDIRECT_TO http://google.com/new-page#modal

This could be a config option when setting redirect_from in the target page's top matter. The syntax could be extended (and remain backwards compatible) to be something like:

redirect_from:
  - /path/to/howdy.html
  - path: /path/to/old.html
    params:
      - from: old

It sounds like @danvk is looking for something like

VISIT http://google.com/oudated-page?q=abc
IF q
  REDIRECT_TO http://google.com/new-page
ELSE
  REDIRECT_TO http://google.com/coolest-page

This doesn't seem possible because the "/oudated-page" path can only resolve to a single file, and the <meta http-equiv="refresh"> tag does not allow conditionals. It would likely require JavaScript to function correctly.

@danvk
Copy link

danvk commented Oct 16, 2014

I'd be very happy if I could include something like this in the frontmatter:

redirect_from:
  - /foo?bar=baz
  - /foo?p=2

@ssorallen
Copy link
Author

@danvk That's not possible with Jekyll alone because Jekyll is simply a static file generator.

For the path "/foo" there exists one real file, which is likely "/foo/index.html". Inside the HTML file, there is a single <meta http-equiv="refresh" content="0;/new-foo"> tag that your browser reads and follows. There is no possibility of branching, i.e. checking URL parameters.

@miguel76
Copy link

It may bit different from both of your needs, but on the same topic. What about passing through hash and query params from the first request to the new URL?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants