Redirect with hash or query params #28

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

Comments

Projects
None yet
5 participants
@ssorallen

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

This comment has been minimized.

Show comment
Hide comment
@danvk

danvk Oct 15, 2014

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

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

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 15, 2014

Member

I think you both might be talking about different things.

Member

parkr commented Oct 15, 2014

I think you both might be talking about different things.

@ssorallen

This comment has been minimized.

Show comment
Hide comment
@ssorallen

ssorallen Oct 16, 2014

@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.

@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

This comment has been minimized.

Show comment
Hide comment
@danvk

danvk 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

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

This comment has been minimized.

Show comment
Hide comment
@ssorallen

ssorallen Oct 16, 2014

@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.

@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

This comment has been minimized.

Show comment
Hide comment
@miguel76

miguel76 Apr 29, 2016

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?

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?

@jekyllbot jekyllbot added the stale label Jun 6, 2016

@jekyllbot jekyllbot closed this Jul 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment