Code Monkey home page Code Monkey logo

Comments (6)

miguel76 avatar miguel76 commented on September 2, 2024 2

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?

from jekyll-redirect-from.

danvk avatar danvk commented on September 2, 2024

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

from jekyll-redirect-from.

parkr avatar parkr commented on September 2, 2024

I think you both might be talking about different things.

from jekyll-redirect-from.

ssorallen avatar ssorallen commented on September 2, 2024

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

from jekyll-redirect-from.

danvk avatar danvk commented on September 2, 2024

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

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

from jekyll-redirect-from.

ssorallen avatar ssorallen commented on September 2, 2024

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

from jekyll-redirect-from.

Related Issues (20)

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.