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

collection file being served as raw file (with no extension) if permalink does not end with "/" #3800

Closed
archywillhe opened this issue Jun 18, 2015 · 18 comments

Comments

@archywillhe
Copy link

@archywillhe archywillhe commented Jun 18, 2015

Suppose I have a collection cats and have this in the front matter of one of the files in _cat/

---
permalink: pageURL

---

when visiting http://domain/pageURL browser will treat it as raw file and download it. (Setting output_ext: ".html" for the collection in _config.yml would yield no change.)

However if I have it as

---
permalink: pageURL.html

---

or

---
permalink: pageURL/

---

the file would be served as a html file instead. (and visiting http://domain/pageURL would go to http://domain/pageUR/ )

Apparently this happens only to collections files because they support multi formats. For post files, even permalink without ending of / will still be served as .html.

@akhyarrh
Copy link

@akhyarrh akhyarrh commented Jun 18, 2015

Try make a new page on jekyll root folder, set it permalink like this:

# filename: test.md
---
permalink: test
---

Test it

bundle exec jekyll build --limit_posts 1

Check your build folder. There's a file named test without extension.

I hope you can understand this.

@archywillhe
Copy link
Author

@archywillhe archywillhe commented Jun 18, 2015

@walutisme I think you didn't get what I mean. Pages and posts both work well with permalink. The raw-file-serving is only happening to collections files.

@envygeeks
Copy link
Contributor

@envygeeks envygeeks commented Jun 18, 2015

You pinged the wrong user.

@archywillhe
Copy link
Author

@archywillhe archywillhe commented Jun 18, 2015

@envygeeks Gosh.. How did that happen... Thanks so much for pointing it out.

@akhyarrh
Copy link

@akhyarrh akhyarrh commented Jun 18, 2015

Well then there's a problem on jekyll collection part. I dont know much, never used it. I just want to explain that raw-file-serving thing are happen to page too if we set it permalink wrong

@Lewiscowles1986
Copy link
Contributor

@Lewiscowles1986 Lewiscowles1986 commented Jun 23, 2015

Does this depend upon the web-server, in which case it is not Jekyll specific issue?

Also I can't see a way around this, because what if I want Jekyll to generate a file without extension? Fixing this would break that

@willnorris
Copy link
Contributor

@willnorris willnorris commented Jun 23, 2015

@0a- what is the name of the source file that is causing this? Do you have this in a public repo somewhere? I'm not able to reproduce this behavior locally (I still get an output file of pageURL.html even with permalink: pageURL), so a good first step would be to see if we can get someone to reproduce what you're seeing.

And just to confirm, what version of jekyll are you running?

@Lewiscowles1986
Copy link
Contributor

@Lewiscowles1986 Lewiscowles1986 commented Jun 23, 2015

@willnorris 2.5.3 for me on Windows

source file /content-sections/clients.html

---
title: clients
permalink: clients
---

generates /_site/clients (no extension)

C:\Users\Lewis\Documents\GitHub\birdyrose.github.io>jekyll --version
jekyll 2.5.3

C:\Users\Lewis\Documents\GitHub\birdyrose.github.io>gem --version
2.4.8

C:\Users\Lewis\Documents\GitHub\birdyrose.github.io>ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]

File is online at birdyrose.github.io (repo of same name)

http://birdyrose.github.io/clients

This means this also affects 2.4.0 which is the gh-pages version.

Again, I move this stays in, if you include forward slash at end of permalink it saves it as index.html, it is a feature, not a bug IMHO 👍

@willnorris
Copy link
Contributor

@willnorris willnorris commented Jun 23, 2015

have you tried this with any of the jekyll 3 releases? A lot of work went into permalinks for jekyll 3 which should handle this case. I'm actually not sure what the expected behavior for this would be for jekyll 2.x

@archywillhe
Copy link
Author

@archywillhe archywillhe commented Jun 23, 2015

oops my bad I forgot to mention the version I was using. @Lewiscowles1986 Yup, the phenomenon occurs in version 2.4.0 running on my ruby 2.2.2 too @willnorris I Just tested it on jekyll 3.0.0.pre.beta7 and the file isn't severed raw 👍 Great work

@archywillhe
Copy link
Author

@archywillhe archywillhe commented Jun 23, 2015

Looks like it was fixed in 0d1586a5c471d322a79177e3e9c2f5813c697c32 by @willnorris 3months ago

@Lewiscowles1986
Copy link
Contributor

@Lewiscowles1986 Lewiscowles1986 commented Jun 23, 2015

Just so I understand, @willnorris patch causes a regression, removing the ability to have permalinks without extension in the unstable and yet-to-be-released, and everyone but me is happy that now we cannot do something we could do before? (FYI, this is not an accusation, this is pointing out that 0d1586a causes a behavior that was supported, to stop working)

@envygeeks
Copy link
Contributor

@envygeeks envygeeks commented Jun 23, 2015

@Lewiscowles1986 the author explicitly said that was not the case for him, is there something that you can input that would lead us to believe it would not be the case for you as well?

@Lewiscowles1986
Copy link
Contributor

@Lewiscowles1986 Lewiscowles1986 commented Jun 23, 2015

If I specify no extension, with no trailing slash; of course I want a file with no extension. It is EXACTLY what I have just told the computer I want... Also worth thinking about, is that collections do not need a permalink in the front-matter, and this does not damage content...

If without an optional permalink being included this happened, I would be 100% on-board that this is a bug; But this only happens when we intentionally break the permalink AFAIM, in the same way you can construct an SQL statement that will not run, or will run and damage the DB; MySQL, SQLite etc do not "shield" the user from this. I think Jekyll should take the same approach.

It is almost always better to educate your users to understand they need the trailing slash or desired file-extension, rather than coddle them, or teach them software should perform actions to correct human behavior, even when explicit... This is where I am coming from

@parkr
Copy link
Member

@parkr parkr commented Jun 23, 2015

Lewis, please don't jump to conclusions. Your comments feel unnecessarily accusatory and it makes those of us spending our free time on this really unwilling to help you.

Will Norris fixed this issue if I read correctly. It should now generate a .html file and support an extensionless path in the request.

@Lewiscowles1986
Copy link
Contributor

@Lewiscowles1986 Lewiscowles1986 commented Jun 23, 2015

Sorry, I am not jumping to conclusions, the "fix" breaks something that worked before, it is really really simple. I am not accusing Will of knowingly breaking others work-flow, but I am saying that is the end result.

It should now generate a .html file and support an extensionless path in the request.

It supported an extension-less path before this, it simply had to be given a / suffix to know to use that feature.

@parkr
Copy link
Member

@parkr parkr commented Jun 23, 2015

The trouble is that permalink is the output value of page.url in Liquid. If you want a clean URL with no extension, but wanted the output file to contain the extension so the server knew what MIME Type to use, you were previously out of luck. What is your use-case for a file on the filesystem with no extension on your Jekyll site?

@Lewiscowles1986
Copy link
Contributor

@Lewiscowles1986 Lewiscowles1986 commented Jun 23, 2015

Forced download of a file via browser, possibly a script. Also now conversion using Jekyll of a data file between formats to an extension-less file

If you want a clean URL with no extension, but wanted the output file to contain the extension so the server knew what MIME Type to use, you were previously out of luck.

Please see

However if I have it as

---
permalink: pageURL.html
---
or

---
permalink: pageURL/
---
the file would be served as a html file instead.

I Honestly believe this was working with increased functionality before-patch, which is why I have raised a separate issue, please lets use #3809 to discuss this further

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.