Skip to content

Instantly share code, notes, and snippets.

@jasonrhodes
Forked from blakesmith/version_reporter.rb
Created October 30, 2013 02:10
Show Gist options
  • Save jasonrhodes/7226155 to your computer and use it in GitHub Desktop.
Save jasonrhodes/7226155 to your computer and use it in GitHub Desktop.
# An example Jekyll generator. Utilizes the new plugin system.
#
# 1. Make a _plugins directory in your jekyll site, and put this class in a file there.
# 2. Upon site generation, version.html will be created in your root destination with
# # the version of Jekyll that generated it
module Jekyll
class VersionReporter < Generator
safe true
def generate(site)
filename = 'version.html'
File.open(File.join(site.config["destination"], filename), 'w') do |f|
f.write(generate_report(site))
end
site.pages << Page.new(site, site.dest, '/', filename)
end
private
def generate_report(site)
"Site generated with Jekyll version: #{Jekyll::VERSION}"
end
end
end
@jasonrhodes
Copy link
Author

I forked and fixed the problem (wish I could submit a PR across gists) but the issue is that you have to add the page into Jekyll's site.pages array after you create the file.

site.pages << Page.new(site, site.dest, '/', filename)

https://gist.github.com/jasonrhodes/7226155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment