Can I somehow make Jekyll include my
file.json which sits in the parent directory of my Jekyll source directory?
It should end up in the root of the created site:
file.json is outside
site.source, it won’t be seen by Jekyll under normal circumstances. The only way out would be write a plugin to include that file at runtime. Paste the following into a file at path
class Generator < Jekyll::Generator
site.static_files << Jekyll::StaticFile.new(site, site.source, "../", "file.json")
The next time you build your site, the
_site/file.json will be generated.
Disclaimer: The above code is untested and may or may not work locally but will definitely not work on GitHub Pages or if you build with
Thanks for your quick answer. Maybe I should have included that I thought using the INCLUDE config setting the file could be included (
include: ['../file.json'])? I ran jekyll with verbose output but it did not report the file as missing but also did not include it when outputting
Cause I am using gh-pages for this site, I’d really not depend on plugins (that are not supported by github).
Is there no other way?
GitHub Pages is very restrictive for security reasons. That’s the reason they do not allow third-party plugins. For the same reason, there is absolutely no straight-forward way to achieve what you’re looking for when serving via GitHub Pages.
The only way is build your site locally and upload the contents of
_site to GitHub (usually to a
gh-pages branch so that the raw source-code can continue residing on the