Here you go, stick the following in _plugins/filename.rb
and the file's basename will be accessible in page.filename
:
require 'pathname'
module Jekyll
class Filename
def self.hook_proc
proc { |page|
page.data['filename'] = Filename.new(Pathname.new(page.path).basename)
}
end
def initialize(filename)
raise "empty filename" if filename.empty?
@filename = filename
end
def to_liquid
@filename
end
end
Hooks.register :pages, :post_init, &Filename.hook_proc
Hooks.register :documents, :post_init, &Filename.hook_proc
end
If you want the whole path, just s/Pathname.new(page.path).basename/page.path/
(and delete require 'pathname'
)