Since 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 docs/_plugins/external_json.rb:
module ExternalJSON
class Generator < Jekyll::Generator
def generate(site)
site.static_files << Jekyll::StaticFile.new(site, site.source, "../", "file.json")
end
end
end
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 --safe switch.
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 _site.
Cause I am using gh-pages for this site, I’d really not depend on plugins (that are not supported by github).
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 master branch.)