Search code examples
rubygithubmonkeypatchingjekylljekyll-extensions

jekyll - add stuff to pages automatically, on github pages


Is there a way to obtain the url of a page on Jekyll? By pages I mean non-post textile files, like about.html and download.html on the following hierarchy:

root
 |
 +- _includes
 |
 +- _layouts
 |
 +- _posts
 |
 +- _config.yml
 |
 +- index.textile
 |
 +- about.textile
 |
 `- download.textile

I'd like to do something like this:

<h1><a href="{{ page.url }}">{{ page.title }}</a></h1>

This works with posts because they have their url included on the post's to_liquid method. Pages on the other hand don't seem to include anything like it - they do have the properties I need (or so it seems), but they don't export them on to_liquid; I'd like to redefine it so it does. Is there a way to do this?

I've found jekyll_extensions, but I don't know if it works on my target environment (github pages).

I'd like to avoid having to include a url parameter on all the yaml heads, if possible.

Thanks a lot!


Solution

  • It looks like page.rb to_liquid does now support the "url" data your need...

    https://github.com/mojombo/jekyll/blob/master/lib/jekyll/page.rb