jekyll / jekyll-redirect-from

:twisted_rightwards_arrows: Seamlessly specify multiple redirections URLs for your pages and posts.
MIT License
781 stars 112 forks source link

Preserve fragment and query string in redirect #123

Closed FokkeZB closed 6 years ago

FokkeZB commented 7 years ago

If I have a redirect from /foo to /bar and I go to /foo?alpha=beta#omega then the query string and fragment are not preserved.

This can only be done in JavaScript of course, so it would requite https://github.com/jekyll/jekyll-redirect-from/blob/master/lib/jekyll-redirect-from/redirect_page.rb#L37 to update (or write?) the meta tag and update the link.

samba commented 7 years ago

👍 , this is an important detail for users of third-party analytics tools (e.g. Google Analytics).

My Ruby is not strong, so I've attempted a patched HTML template only: https://gist.github.com/samba/01c4a07ab73d1bacd23a9f3115e8978c

FokkeZB commented 7 years ago

Thanks @samba, I turned it into a PR with some further edits: #127

jekyllbot commented 7 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

FokkeZB commented 7 years ago

Thanks @jekyllbot, however there's already a PR waiting to close this issue:

https://github.com/jekyll/jekyll-redirect-from/pull/127

mpchadwick commented 6 years ago

FYI for anyone else who lands on this, I wrote a blog post with a workaround here https://maxchadwick.xyz/blog/preserving-the-hash-and-query-string-with-jekyll-redirects

tl;dr; If you want this behavior just commit the HTML redirect file to your repo with the required JavaScript.

@pathawks based on your latest comment maybe this issue should be closed?

pathawks commented 6 years ago

@mpchadwick Yes, I suppose you are right.

Thank you for posting your workaround! Users should be able to implement that behavior if they need it. However, I feel this plugin should be focused on keeping things as simple as possible, and this feature is not a good fit at this time.