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_to appears not to work #107

Closed
gboone opened this issue May 13, 2016 · 12 comments · Fixed by #111
Closed

redirect_to appears not to work #107

gboone opened this issue May 13, 2016 · 12 comments · Fixed by #111

Comments

@gboone
Copy link

gboone commented May 13, 2016

Hello, we've been using this product for a while now and recently noticed all of our pages that use redirect_to are not redirecting to the expected destination.

As an example: this URL https://18f.gsa.gov/tags/day%20in%20the%20life/ should redirect to this url: https://18f.gsa.gov/tags/day-in-the-life/ but as you can see it generates a blank page instead. Here's the source file that generates that page.

I haven't tested it with all the pages using redirect_to but /tags/demo day/ and /how we work/ are also failing.

Pages using redirect_from appear to be working correctly.

@gboone
Copy link
Author

gboone commented May 13, 2016

More background! Sleuthing by @jeremiak has shown that adding index.html to the end of the permalink you want to redirect will make it work. See, for example, this file: https://github.com/18F/18f.gsa.gov/blob/4437b6f57e1374c1d61e1638e509aac095be62aa/pages/feed.md

To correct one of the examples above:

Bad:

---
permalink: /tags/day in the life/
redirect_to:
  - /tags/day-in-the-life/
---

Good:

---
permalink: /tags/day in the life/index.html
redirect_to:
  - /tags/day-in-the-life/
---

@pathawks
Copy link
Member

It looks like redirect_to only overrides the item.content and not any of the item.data.

https://github.com/jekyll/jekyll-redirect-from/blob/v0.10.0/lib/jekyll-redirect-from/redirector.rb#L30-L31

I would guess that the problem is that the page has a default layout set, and we should be turning it off here, but we are not.

No idea what adding index.html could be changing though.

@gboone
Copy link
Author

gboone commented May 13, 2016

I would guess that the problem is that the page has a default layout set, and we should be turning it off here, but we are not.

Interesting, I'll give that a shot and see if it helps.

@koron
Copy link

koron commented May 30, 2016

I have investigated this as below:

@rowleya
Copy link

rowleya commented May 31, 2016

I can confirm this also - the page generated is called index not index.html. If you manually put in "index" instead of index.html, my browser downloads a file which contains the redirect html code. Note that other page redirects work fine - it is just the name index that seems to go wrong.

@rowleya
Copy link

rowleya commented May 31, 2016

Incidentally, you can work around the issue by replacing the index.md with an index.html with redirect code in it:

<html>
    <head>
        <meta http-equiv="refresh" content="0; url=https://my-url/">
    </head>
</html>

@koron
Copy link

koron commented May 31, 2016

it is just the name index that seems to go wrong.

It is correct, but not enough.

When using permalink: pretty, all pages will use index as name (URL is ended with /).
So all sites which use permalink: pretty or similar style, are affected by this.

@koron
Copy link

koron commented May 31, 2016

I have created a PR to fix this, please check it (#108)

@ferrantim
Copy link

what is the status of this issue? We're seeing the same problem.

@parkr
Copy link
Member

parkr commented Jun 14, 2016

I have not had time to look into this unfortunately. Would you be able to
setup a reproducible site in a repo quickly for me so we can debug more
easily?

Michael Ferranti notifications@github.com schrieb am Di., 14. Juni 2016
um 11:53:

what is the status of this issue? We're seeing the same problem.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub
#107 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAOhoTRz541CVJXAq_mC2W7kf632LaZTks5qLvi4gaJpZM4IeZCQ
.

@ferrantim
Copy link

ferrantim commented Jun 14, 2016

@parkr Does it help to mention that we're using the github-pages gem? I don't know when this stopped working exactly, but it was definately working before, so probably somethign with github-pages.

@gboone
Copy link
Author

gboone commented Jun 14, 2016

@parkr Not sure if this is what you mean but we're using it on 18f.gsa.gov. This URL https://18f.gsa.gov/tags/how%20we%20work/ should redirect to https://18f.gsa.gov/tags/how-we-work/ The repo is at https://github.com/18f/18f.gsa.gov

gboone pushed a commit to 18F/18f.gsa.gov that referenced this issue Jul 19, 2016
This should fix many currently broken redirects. For more information
about the problem solved, see this issue and the pull requests
referenced: jekyll/jekyll-redirect-from#107
@jekyll jekyll locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
7 participants