Access datafile by AJAX

I have got a JSON datafile which contains group of dates for calendar jquery plugin. Can I access files in Hugo “data” folder by AJAX? What URL should it be? Because “/data/calendar.json” doesn’t work - it returns 404 response.

Static is the folder that’s exposed after you publish.

Let me clarify my problem

Files in “data” folder can be edit in Forestry CMS and i want to preserve that ability. I think I may move this file to “static” folder during build process if accessing to “data” folder isn’t possible.

Hugo can access the data folder in its normal location during Hugo’s build. But Ajax runs when you browse the site, does it not?

What if your jquery plugin accessed a symlink of the data file? Can you symlink it into, say, static/data?

For AJAX, putting JSON files into “page bundles” is an exellent alternative.

1 Like