Skip to content

Instantly share code, notes, and snippets.

@rampatra
Last active March 15, 2020 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rampatra/82776daacc2ece5a9d230d6f7d1538b5 to your computer and use it in GitHub Desktop.
Save rampatra/82776daacc2ece5a9d230d6f7d1538b5 to your computer and use it in GitHub Desktop.
Generate a json file with all the posts in your Jekyll website
---
layout: null
---
[
{% for post in site.posts %}
{
"title" : "{{ post.title }}",
"url" : "{{ post.url }}",
"date" : "{{ post.date | date: "%b %d, %Y" }}",
"content" : "{{ post.content | strip | strip_html | strip_newlines | replace: '"', '' | slice: 0, 600 }}"
}{% if forloop.last %}{% else %},{% endif %}
{% endfor %}
]
@rampatra
Copy link
Author

I needed this to add search functionality on my Jekyll website: https://blog.rampatra.com/how-to-add-search-in-jekyll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment