Skip to content

Instantly share code, notes, and snippets.

@LeonardoCardoso
Last active January 1, 2020 19:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeonardoCardoso/32fd697ef3f7279d3b2fd59645febaf4 to your computer and use it in GitHub Desktop.
Save LeonardoCardoso/32fd697ef3f7279d3b2fd59645febaf4 to your computer and use it in GitHub Desktop.
Jekyll XML RSS Feed
---
layout: null
permalink: /feed.xml
---
{% assign feed_url = page.url | absolute_url %}<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ site.title }}</title>
<subtitle>By {{ site.author.name }}</subtitle>
<link rel="alternate" type="text/html" href="{{ site.url }}" />
<link rel="self" type="application/atom+xml" href="{{ feed_url }}" />
<id>{{ feed_url }}</id>
<updated>{{ site.posts[0].date | date_to_xmlschema }}</updated>
<rights>Copyright © {{ 'now' | date: "%Y" }}, {{ site.author.name }}</rights>
{% assign posts = site.posts | where_exp: "post", "post.draft != true" %} {% for post in posts limit: 50 %} {% if post.feed == true %}
<entry>
<title>{{ post.title }}</title>
<link rel="alternate" type="text/html" href="{{ post.external_url | default: post.permalink | absolute_url }}" />
<link rel="related" type="text/html" href="{{ post.permalink | absolute_url }}" />
<id>{{ post.permalink | absolute_url }}</id>
<published>{{ post.date | date_to_xmlschema }}</published>
<updated>{{ post.update_date | default: post.date | date_to_xmlschema }}</updated>
<author>
<name>{{ post.author.name }}</name>
<uri>{{ post.author.uri | default: site.url }}</uri>
</author>
<content type="html" xml:base="{{ site.url }}" xml:lang="en">
<![CDATA[
{{ post.content }}
]]>
</content>
</entry>{% endif %}{% endfor %}
</feed>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment