Skip to content

Instantly share code, notes, and snippets.

@ckunte
Last active March 7, 2020 01:01
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 ckunte/162a0c890d3c98c37e704a9c5664356d to your computer and use it in GitHub Desktop.
Save ckunte/162a0c890d3c98c37e704a9c5664356d to your computer and use it in GitHub Desktop.
JSON feed template in Jinja
{% from 'site_settings.jinja2' import site_title, site_author, site_url -%}
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ site_title }}",
"description": "Description of the website",
"home_page_url": "{{ site_url }}",
"feed_url": "{{ site_url }}/feed.json",
"author": {
"name": "{{ site_author }}",
"url": "{{ site_url }}"
},
"items": [
{%- for entry in entries %}
{
"title": {{ entry.title | tojson }},
"date_published": "{{ entry.year }}-{{ entry.month }}-{{ entry.day }}T{{ entry.hour }}:{{ entry.minute }}:{{ entry.second }}+00:00",
"url": "{{ site_url}}/{{ entry.url }}",
"id": {{ entry.url | tojson }},
"content_text": {{ entry.summary | tojson }},
"content_html": {{ entry.content | tojson }}
}{%if not loop.last %},{%endif%}
{%- endfor %}
]
}
# Site settings
# Site name
{%- set site_title = "yoursite.net" -%}
# Site url (end without /)
{%- set site_url = "https://yoursiteurl.net" -%}
# Author
{%- set site_author = "Your Name" -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment