Jekyll v3.0 Compatibility
metaskills opened this issue · 5 comments
I noticed this morning that Jekyll v3 has this in their change log. Mimic GitHub Pages .html extension stripping behavior in WEBrick (jekyll/jekyll#3452). I found that hacking get_filename
in my config.ru to something like this works. Would you be open to a pull request and how would you recommend support v2 and v3 at the same time?
elsif !@files.include?(fullpath)
normalized = fullpath + ".html"
Thanks in advance!
My thought is to not provide support for both Jekyll 2.x and Jekyll 3.x in the same version. With 0.4.2 recently released, that should be the version that people use to support Jekyll 2. Once we have Jekyll 3 support in place, then a newer version should be released and folks should use that. 😃
We'd be happy to see a pull request that supports the same GitHub Pages .html extension stripping behavior.
Cool, I like the idea of versioned gem with n-n-stable
branches too. In one of our Jekyll sites we used jekyll-paginate gem so our hack ended up being something like.
+ if fullpath.end_with?("/")
+ normalized = fullpath + "index.html"
+ elsif fullpath.match(/\/page\d+\Z/)
+ normalized = fullpath + "/index.html"
-
Regarding monkey patches and PRs:
Be aware that right now there is ongoing work with various bug fixes and a general cleanup. In my development branch the above mentioned code portion has already changed (mainly due to #39), more changes are likely to happen.
Have you considered using e.g. the Rack::Rewrite middleware as an alternative? That would seem much cleaner to me.
-
Regarding Jekyll 3 support: I absolutely would prefer a gem that works with both, so users are not forced to switch. Depends of course on the kind of changes in Jekyll 3, which I haven't looked into yet.
-
Regarding
.html
stripping in particular, personally I find it a little bit confusing. Having the filespage.html
andpage/index.html
, wouldpage
as URL path referencepage.html
orpage/
(=page/index.html
)? Many people would expect the trailing slash to not make a difference.
So... I think I found out that my issue was self induced. My permalink was set to something like this /blog/:year/:month/:day/:title
. Note the lack of a trailing slash. All I had to do to fix my local rack setup was to fix my usage of Jekyll by changing this to /blog/:year/:month/:day/:title/
with a trailing slash. This also had the upside of fixing all my existing permalink after upgrading to Jekyll v3.
Yeah, thanks @metaskills -- I just needed the add the slash to the end of my custom permalink on a single one-off page that was failing. Without the slash, was working fine when served via built-in server, but not with rack-jekyll.
I think this is related, for anyone investigating later: https://jekyllrb.com/docs/permalinks/#extensionless-permalinks
This rewrite rule in config.ru seems to make it so the user doesn't need to be so picky with adding the trailing slash (since regular content editors will be working with the front-matter :)
require 'rack/rewrite'
use Rack::Rewrite do
rewrite %r{(/.+)?/([^\./]+)$}, '$1/$2.html'
end
Do we want to put this anywhere in the documentation?