I don't think there's a good way of doing it with Jekyll as-is. convertible.rb
only passes the site
object to Liquid, which doesn't contain any page-specific data.
I'd suggest just editing convertible.rb
to pass in the data you need, submitting a pull request to the main project to pull in your changes, and using your fork locally to generate your site. Hooray for open source!
The following trivial patch works for me locally against Jekyll 0.11.0, making a page hash available in Liquid as context.registers[:page]
(note: it's a pre-converted hash at this point, so you'd access context.registers[:page]['url']
, not context.registers[:page].url
):
diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb
index d33abc5..a674ef5 100644
--- a/lib/jekyll/convertible.rb
+++ b/lib/jekyll/convertible.rb
@@ -69,7 +69,7 @@ module Jekyll
#
# Returns nothing.
def do_layout(payload, layouts)
- info = { :filters => [Jekyll::Filters], :registers => { :site => self.site } }
+ info = { :filters => [Jekyll::Filters], :registers => { :site => self.site, :page => payload['page'] } }
# render and transform content (this becomes the final content of the object)
payload["pygments_prefix"] = converter.pygments_prefix
Hope that helps!