Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (26 sloc) 738 Bytes
layout title
post
JSONify your Jekyll Site

Recently, I wanted to be able to dynamically load posts on my jekyll site. One way to achieve this is to generate the entirety of your site in json.

I created a file called site.json and added these contents:

{% highlight html %} {% raw %}

layout: nil

[ {% for post in site.posts %} { "title" : "{{ post.title }}", "url" : "{{ post.url }}", "date" : "{{ post.date | date: "%B %d, %Y" }}", "content" : "{{ post.content | escape }}" } {% if forloop.last %}{% else %},{% endif %} {% endfor %} ] {% endraw %} {% endhighlight %}

If you omit the escape by "content", double quotes in your content might break your json.

Happy Ajaxing!

You can’t perform that action at this time.