You can access the Jekyll configuration this way:
require 'jekyll'
conf = Jekyll.configuration({})
#=> {
# "source" => "/Users/me/some_project",
# "destination" => "/Users/me/some_project/_site",
# ...
# }
conf["destination"]
#=> "/Users/me/some_project/_site"
You can use this in your Rakefile this way:
require 'jekyll'
CONF = Jekyll.configuration({})
task :something do
public_dir = CONF["destination"]
Dir.glob("#{public_dir}/**/*.{htm,html}").each do |ourfile|
# ...
end
end
Note that I have added #{}
around public_dir
in the argument to Dir.glob
, otherwise this would be looking for the literal directory public_dir/
instead of the actual destination directory.