Skip to content

Instantly share code, notes, and snippets.

@roachhd
Last active October 26, 2025 01:01
Show Gist options
  • Save roachhd/f664d2cae2da899be3f6 to your computer and use it in GitHub Desktop.
Save roachhd/f664d2cae2da899be3f6 to your computer and use it in GitHub Desktop.

Revisions

  1. roachhd revised this gist Nov 21, 2014. 1 changed file with 0 additions and 22 deletions.
    22 changes: 0 additions & 22 deletions LICENSE.md
    Original file line number Diff line number Diff line change
    @@ -1,22 +0,0 @@
    The MIT License (MIT)

    Copyright (c) 2014 George Mandis

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

  2. roachhd revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Jekyll RSS Feed Templates
    Jekyll RSS Feed Templates.
    =========================

    A few Liquid templates to use for rendering RSS feeds for your Jekyll blog. Featuring four kinds of feeds:
  3. roachhd created this gist Nov 21, 2014.
    22 changes: 22 additions & 0 deletions LICENSE.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    The MIT License (MIT)

    Copyright (c) 2014 George Mandis

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

    34 changes: 34 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    Jekyll RSS Feed Templates
    =========================

    A few Liquid templates to use for rendering RSS feeds for your Jekyll blog. Featuring four kinds of feeds:

    - **feed.xml** — Renders the 10 most recent posts.
    - **feed.category.xml** — Only renders posts for a specific category. This example renders posts for a "miscellaneous" category.
    - **feed.links.xml** &mdash; Only contains posts that link to external websites noted by a <code>link</code> variable in the [YAML Front Matter](https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter). Not a common Jekyll convention, but a good way to generating a linked list.
    - **feed.articles.xml** &mdash; Only showing articles that don't link to external sites; The opposite of <code>feed.links.xml</code>.

    How to use
    ----------
    - Update \_config.yml as noted below, or manually replace the variables.
    - Copy one of the xml (ie, <code>feed.xml</code>) files to the root directory of your Jekyll blog.
    - Run <code>jekyll</code>.

    In your generated <code>\_site</code> folder you should find a properly formatted feed at <code>feed.xml</code>.

    Customizing \_config.yml
    ------
    These templates rely on a customized version of <code>\_config.yml</code>. The following lines have been added:

    name: Your Blog's Name
    description: A description for your blog
    url: http://your-blog-url.example.com

    This makes it easy to reference the title, description and URL for your site in the feed templates using <code>{{ site.name }}</code>, <code>{{ site.description }}</code> and <code>{{ site.url }}</code>. Even if you're not using these feed templates, you might find these variables useful when you're designing your layouts.


    Miscellany
    -----------
    - **Note on YAML Front Matter block**: The xml files contain a [YAML Front Matter](https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter) block with the line <code>layout: none</code>. This is necessary because Jekyll will not process a page with Liquid unless there is a YAML block at the top of the file.
    - **RSS Autodiscovery**: If your template is not already setup to do so, make sure the RSS feeds are discoverable by browsers, bots, etc: [rssboard.org/rss-autodiscovery](http://www.rssboard.org/rss-autodiscovery)
    - **Validation**: You can use the W3C Validator to make sure your feeds are formatted correctly: [http://validator.w3.org/feed/](http://validator.w3.org/feed/)
    23 changes: 23 additions & 0 deletions feed.articles.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    ---
    layout: none
    ---
    <?xml version="1.0" encoding="UTF-8"?>
    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
    <title>{{ site.name | xml_escape }} - Articles</title>
    <description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>
    <link>{{ site.url }}</link>
    <atom:link href="{{ site.url }}/feed.articles.xml" rel="self" type="application/rss+xml" />
    {% for post in site.posts %}
    {% unless post.link %}
    <item>
    <title>{{ post.title | xml_escape }}</title>
    <description>{{ post.content | xml_escape }}</description>
    <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
    <link>{{ site.url }}{{ post.url }}</link>
    <guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid>
    </item>
    {% endunless %}
    {% endfor %}
    </channel>
    </rss>
    21 changes: 21 additions & 0 deletions feed.category.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    ---
    layout: none
    ---
    <?xml version="1.0" encoding="UTF-8"?>
    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
    <title>{{ site.name | xml_escape }} - Miscellaneous</title>
    <description>Posts categorized as 'miscellaneous'</description>
    <link>{{ site.url }}</link>
    <atom:link href="{{ site.url }}/feed.category.xml" rel="self" type="application/rss+xml" />
    {% for post in site.categories.miscellaneous limit:10 %}
    <item>
    <title>{{ post.title | xml_escape }}</title>
    <description>{{ post.content | xml_escape }}</description>
    <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
    <link>{{ site.url }}{{ post.url }}</link>
    <guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid>
    </item>
    {% endfor %}
    </channel>
    </rss>
    23 changes: 23 additions & 0 deletions feed.links.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    ---
    layout: none
    ---
    <?xml version="1.0" encoding="UTF-8"?>
    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
    <title>{{ site.name | xml_escape }} - Links</title>
    <description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>
    <link>{{ site.url }}</link>
    <atom:link href="{{ site.url }}/feed.links.xml" rel="self" type="application/rss+xml" />
    {% for post in site.posts %}
    {% if post.link %}
    <item>
    <title>{{ post.title | xml_escape }}</title>
    <description>{{ post.content | xml_escape }}</description>
    <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
    <link>{{ post.link | escape }}</link>
    <guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid>
    </item>
    {% endif %}
    {% endfor %}
    </channel>
    </rss>
    21 changes: 21 additions & 0 deletions feed.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    ---
    layout: none
    ---
    <?xml version="1.0" encoding="UTF-8"?>
    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
    <title>{{ site.name | xml_escape }}</title>
    <description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>
    <link>{{ site.url }}</link>
    <atom:link href="{{ site.url }}/feed.xml" rel="self" type="application/rss+xml" />
    {% for post in site.posts limit:10 %}
    <item>
    <title>{{ post.title | xml_escape }}</title>
    <description>{{ post.content | xml_escape }}</description>
    <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
    <link>{{ site.url }}{{ post.url }}</link>
    <guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid>
    </item>
    {% endfor %}
    </channel>
    </rss>