Skip to content

Instantly share code, notes, and snippets.

@aahan
Last active December 15, 2015 08:09
Show Gist options
  • Save aahan/5228376 to your computer and use it in GitHub Desktop.
Save aahan/5228376 to your computer and use it in GitHub Desktop.
Jekyll RSS feed template based on WordPress' RSS feed template.

feed.xml

---
layout: nil
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>

<channel>
	<title><![CDATA[{{ site.title }}]]></title>
	<atom:link href="{{ site.url }}/feed.xml" rel="self" type="application/rss+xml" />
	<link href="{{ site.url }}/" />
	<description><![CDATA[{{ site.subtitle }}]]></description>
	<lastBuildDate>{{ site.time | date: "%a, %d %b %Y %H:%M:%S %z" }}</lastBuildDate>
	<language>en-US</language>
	<generator uri="http://octopress.org/">Octopress</generator>

	{% for post in site.posts limit: 15 %}
		<item>
			<title><![CDATA[{{ post.title | cdata_escape }}]]></title>
			<link>{{ site.url }}{{ post.url }}</link>
			<pubDate>{{ post.date | date: "%a, %d %b %Y %T %z" }}</pubDate>
			<dc:creator><![CDATA[{{ site.author | strip_html }}]]></dc:creator>
		{% for category in post.categories %}
			<category><![CDATA[{{ category | cdata_escape }}]]></category>
		{% endfor %}
		{% for category in post.tags %}
			<category><![CDATA[{{ category | cdata_escape }}]]></category>
		{% endfor %}
			<guid>{{ site.url }}{{ post.url }}</guid>
			<description>
				<![CDATA[{{ post.content | strip_html | truncatewords: 50 | expand_urls: site.url | cdata_escape }}]]>
			</description>
			<content:encoded>
				<![CDATA[{{ post.content | expand_urls: site.url | cdata_escape }}]]>
			</content:encoded>
		</item>
	{% endfor %}

</channel>

</rss>

Every link that helped:

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