# Include json file from one level up outside SOURCE dir

**URL:** https://talk.jekyllrb.com/t/include-json-file-from-one-level-up-outside-source-dir/3530
**Category:** Help
**Created:** [November 2, 2019, 2:45pm UTC](https://talk.jekyllrb.com/t/include-json-file-from-one-level-up-outside-source-dir/3530 "2019-11-02T14:45:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![pke](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/pke/32/2009_2.png) [@pke](https://talk.jekyllrb.com/u/pke)
#### Post date: [November 2, 2019, 2:45pm UTC](https://talk.jekyllrb.com/t/include-json-file-from-one-level-up-outside-source-dir/3530/1 "2019-11-02T14:45:52Z")

</div>

Can I somehow make Jekyll include my `file.json` which sits in the parent directory of my Jekyll source directory?

```
+ docs
  + _site
  - _config.yml
- file.json

```

It should end up in the root of the created site:

```
+ docs
  + _site
    - file.json
  - _config.yml
- file.json

```

Thanks!

---

<div class="post-metadata">

### Author: ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)
#### Post date: [November 2, 2019, 3:18pm UTC](https://talk.jekyllrb.com/t/include-json-file-from-one-level-up-outside-source-dir/3530/2 "2019-11-02T15:18:48Z")

</div>

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`** :

```ruby
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._

---

<div class="post-metadata">

### Author: ![pke](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/pke/32/2009_2.png) [@pke](https://talk.jekyllrb.com/u/pke)
#### Post date: [November 2, 2019, 5:14pm UTC](https://talk.jekyllrb.com/t/include-json-file-from-one-level-up-outside-source-dir/3530/3 "2019-11-02T17:14:14Z")

</div>

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).

Is there no other way?

---

<div class="post-metadata">

### Author: ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)
#### Post date: [November 3, 2019, 5:51pm UTC](https://talk.jekyllrb.com/t/include-json-file-from-one-level-up-outside-source-dir/3530/4 "2019-11-03T17:51:02Z")

</div>

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.)
