Skip to content

Instantly share code, notes, and snippets.

@timschroederme
Last active December 10, 2015 10:48
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 timschroederme/4423051 to your computer and use it in GitHub Desktop.
Save timschroederme/4423051 to your computer and use it in GitHub Desktop.
Feed template file for use with the PieCrust CMS static website generator.
Just add a the feed.xml file to the /_content/pages folder of your local website setup and PieCrust will generate a feed.xml file in your website root folder during baking.
In your website index page, you can (and should) have a link to your feed. You could either have a visible link in the body of the page that looks like this:
http://yourdomain.com/feed.xml
Another common approach is to have an (invisible) link to your feed in the head part of your index page.
This allows feed reader software to detect your feed.
If you use the website template delivered with PieCrust, you should edit the default.html file, which is located in the /_content/templates folder of your website, and add this line to the head part of the template:
<link rel=”alternate” type=”application/rss+xml” href=”http://yourdomain.com/feed.xml” />
---
title: yourdomain.com feed
layout: none
format: none
posts_per_page: 10
single_page: true
---
<?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>{{site.title}}</title>
<atom:link href="http://yourdomain.com/feed.xml" rel="self" type="application/rss+xml" />
<link>http://yourdomain.com</link>
<description></description>
<lastBuildDate>{{now|date("r")}}</lastBuildDate>
<language>en-US</language>
<generator>PieCrust {{piecrust.version}}</generator>
{% for post in pagination.posts %}
<item>
<title>{{post.title}}</title>
<pubDate>{{post.date|date("r")}}</pubDate>
<link>{{post.url}}</link>
<dc:creator>{{site.author}}</dc:creator>
<description>{{post.content}}</description>
</item>
{% endfor %}
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment