I have a repository on github which contains a number of csv, json, yml data files in the root directory of the repository.
How do I get it to serve those files using Github Pages?
So for eg: when I go to http://username.github.io/reponame/
followed by
/posts
- serve the contents of the posts.json file/users
- serve the contents of the users.json file/comments
- serve the contents of the comments.json file/posts.csv
- serve the contents of the posts.csv fileYou just need to add .json
files in your repository and you can access them like a normal JSON API
In the following repository username.github.io/reponame
add following files
posts.json
[
{"id": 1, "title": "Title 1"},
{"id": 2, "title": "Title 2"}
]
users.json
[
{"name": "abc", "email": "[email protected]"},
{"name": "xyz", "email": "[email protected]"}
]
comments.json
[
{"post_id": "1", "text": "Comment 1"},
{"post_id": "2", "text": "Comment 2"}
]
posts.csv
id,title
1,Title 1
2,Title 2
And access them with
http://username.github.io/reponame/posts.json
http://username.github.io/reponame/users.json
http://username.github.io/reponame/comments.json
http://username.github.io/reponame/posts.csv