score:1

Accepted answer

I also posted to the Ghost community and a very nice person there had the solution. He said Ghost doesn't send json files from themes for security reasons. He recommended using "the content-type feature in Dynamic Routing to “render” a template (which is really a json file)."

So now my route.yaml file looks like

routes:
  /:
    controller: channel
    data: page.home
    template: 
      - home
  /data/geo/:
    template: 
    - geo
    content-type: json
collections:
  /blog/:
    permalink: /blog/{slug}/
    template: 
      - index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

I renamed custom.geo.json to geo.hbs and left in the theme folder.

and my js code is :

d3.json(
  "/data/geo/", function(json) {

score:0

If you don't want to change the ghost routing and you've got nginx as a reverse proxy in front of ghost you can serve the json using the location directive.

See the config sketch.

server {
     ...
     ...
    location / {
        proxy_pass http://localhost:2368;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}
location /data/geo.json {
    alias path/to/geo.json;
}

Related Query