[Solved] Failed in using jQuery access CSV file with custom domain

I am using jQuery to (locally) access CSV file hosted in git host to build a chart. Everything runs smooth when I using the domain my-projects.git.io

However, when I begin to use Custom domain. The charts doesn’t work any more since jQuery does not allow us to access csv file on cross domain. This means I am standing at the domain (mydomain) and request a csv file on git.io (other domain)

Could you please show me the way to deal with this issues.

@glorevenhite Unfortunately, your question is really about cross-domain/mixed content errors and jQuery, all of which really have nothing to do with HUGO.


That said, Hugo’s many powerful features include processing data files…including those exposed via URL. I would take a look at the data drive files section of the docs

But of course, this creates static content from your data files, and I have no idea how dynamic these data files and resulting output need to be…

1 Like

You know, I created a content type name report, I also specified the layout in the front matter as well. In the layout file, I inserted a partial in which I defined a url to csv file located in static folder. This url would be parsed to the jQuery function that will create the chart.

Every time I create a new report, I simply clone a new layout, specify new layout in front matter. Make some changes in layout file (I may define new url and parse via partials ). So I have a new post with a new chart.

Things work very well when I use the domain mysite.git.io; however, it no longer works since I use the custom domain. So as I’ve been with Hugo a couple days, I initially might think the problem comes due the mechanism of Hugo in working with Github on custom domain.

I’ve made a change in which I use the …/…/ to access my file instead of using the .Site.BaseURL. And it works now. I also using data driven files as you recommend and it works too.

Thank you so much!