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

Mimic GitHub Pages .html extension stripping behavior #3452

Merged
merged 2 commits into from Feb 14, 2015

Conversation

Projects
None yet
4 participants
@rtomayko
Contributor

rtomayko commented Feb 13, 2015

This modifies the WEBrick server started by jekyll serve such that a file "/foo.html" can be requested at "/foo". The behavior mirrors the GitHub Pages server configuration closely: first check for a file in the original location and then fallback to checking for file + .html extension.

The response's Content-Type ("text/html"), Content-Length, ETag, and Last-Modified headers are all set appropriately, as if the request was made with the .html suffix.

See the individual commits for additional remarks on the implementation.

/cc #156, #2021, holman/ama#231

rtomayko added some commits Feb 13, 2015

Custom WEBrick FileHandler for stripping .html extension
This first performs the normal static file check at the exact
location. If no file is found, attempt the check again with an
".html" suffix.

See the following for base class search_file implementation:

https://github.com/ruby/ruby/blob/4607f95/lib/webrick/httpservlet/filehandler.rb#L363-L383
Avoid requiring webrick at boot time
This is a bit uglier but allows deferring loading webrick until the
serve command is invoked as opposed to when it's required.
@mattr-

This comment has been minimized.

Show comment
Hide comment
@mattr-

mattr- Feb 13, 2015

Member

Nice! Thanks @rtomayko!

@parkr?

Member

mattr- commented Feb 13, 2015

Nice! Thanks @rtomayko!

@parkr?

@parkr parkr merged commit 7c9ad82 into jekyll:master Feb 14, 2015

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

parkr added a commit that referenced this pull request Feb 14, 2015

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Feb 14, 2015

Member

Looks great, thanks Ryan. We'll release this in Jekyll 3.0. 👍

Member

parkr commented Feb 14, 2015

Looks great, thanks Ryan. We'll release this in Jekyll 3.0. 👍

@rtomayko

This comment has been minimized.

Show comment
Hide comment
@rtomayko

rtomayko Feb 14, 2015

Contributor

Beautiful, thanks!

Contributor

rtomayko commented Feb 14, 2015

Beautiful, thanks!

chanil1218 added a commit to castellar/someting.me that referenced this pull request Mar 3, 2016

Add extensionless permalinks supported after jekyll 3.0
Detail : For "permalink: /restaurants", use _sites/restaurants.html
Previsouly forced to use "permalink: /restaurants/" that makes
_sites/restaurants/index.html
Result : Permalink wihtout trailing slash(/restaurants"/") could be possible.
Reference :
 - http://jekyllrb.com/docs/permalinks/#extensionless-permalinks
 - jekyll/jekyll#3452

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