Skip to content

Instantly share code, notes, and snippets.

@zhuochun
Last active June 14, 2023 17:46
Show Gist options
  • Save zhuochun/fe127356bcf8c07ae1fb to your computer and use it in GitHub Desktop.
Save zhuochun/fe127356bcf8c07ae1fb to your computer and use it in GitHub Desktop.
List all posts, tags and categories in Jekyll. https://github.com/zhuochun/md-writer

List all posts, tags and categories in Jekyll.

Octopress users: if you found " is escaped in the generated JSON file, please change them to \". Refer to this issue.

---
layout: null
---
{
"categories": [
{% for category in site.categories %}
"{{ category | first }}"{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
---
layout: null
---
{
"posts": [
{% for post in site.posts %}
{
"title": "{{ post.title | xml_escape }}",
"url": "{{ site.url }}{{ post.url }}",
"date": "{{ post.date | date_to_xmlschema }}"
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
---
layout: null
---
{
"tags": [
{% for tag in site.tags %}
"{{ tag | first }}"{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
@JerryChin
Copy link

That's very helpful!

@MichaelOrtho
Copy link

Thank you, very helpful!

@linhandev
Copy link

Really Useful!!

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