How to make a podcast RSS feed

How to make a podcast RSS feed

Ghost includes automatic RSS feeds for your content out of the box, but you can also easily create a custom feed for your podcast with routes and templates.


Adding /rss/ to most URLs in Ghost produces an automatically generated RSS feed for your content. If you’re publishing a podcast on your Ghost site then you’ll probably want to create a custom RSS feed to distribute your podcast episodes to places like iTunes or Google Podcasts.

Automatic RSS feed generated by Ghost
Automatic RSS feed generated by Ghost

This tutorial walks you through how to create a fully podcast RSS feed fully optimized for iTunes by creating a custom template and dynamic routing.

Add a new route for your RSS feed

Let's create a new route for the RSS feed by editing the site's routes. Download the most up-to-date version of your routes.yaml file from Ghost Admin and open it in a code editor.

Let's first add a podcast collection, which will filter out our podcast posts from the homepage.

collections:
  /podcast/:
    permalink: /podcast/{slug}/
    filter: tag:podcast
  /:
    permalink: /{slug}/

Then, define a custom route for the RSS feed. This route specifies a custom template, podcast/rss, and that the content_type is XML, which is what's expected for an RSS feed.

routes:
  /podcast/rss/:
    template: podcast/rss
    content_type: text/xml

All together, your routes.yaml file should look like this:

routes:
  /podcast/rss/:
    template: podcast/rss
    content_type: text/xml
    
collections:
  /podcast/:
    permalink: /podcast/{slug}/
    filter: tag:podcast
  /:
    permalink: /{slug}/
    template: index
    
taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Upload your updated routes file to your Ghost site.

Create a custom RSS template

On the podcast/rss route, we told Ghost to look for a specific template to render the RSS feed. We now need to create that template.

Create the template by making a new file called rss.hbs in the podcast folder of your theme. iTunes and other podcast platforms require specific formatting in order to understand your feed. They define the type of RSS feed and some basic information about your podcast. Below is an example of what's required, which you can copy into your own template and replace with the necessary information:

<?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/"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0">
    <channel>
        <title>{{@site.title}}</title>
        <link>{{@site.url}}</link>
        <description>{{@site.description}}</description>
        <language>{{@site.locale}}</language>
        <copyright>{{@site.title}} Copyright {{date format="YYYY"}}</copyright>
        <atom:link href="{{@site.url}}/podcast/rss/" rel="self" type="application/rss+xml" />
        <lastBuildDate>{{date format="ddd, DD MMM YYYY HH:mm:ss ZZ"}}</lastBuildDate>
        <itunes:author>{{@site.title}}</itunes:author>
        <itunes:summary>{{@site.description}}</itunes:summary>
        <itunes:owner>
            <itunes:name>Your Name</itunes:name>
            <itunes:email>youremail@example.com</itunes:email>
        </itunes:owner>
        <itunes:explicit>clean</itunes:explicit>
        <itunes:image href="{{img_url @site.icon absolute="true"}}"/>
        <itunes:category text="Technology"></itunes:category>

        {{#get "posts" filter="tag:podcast" include="tags,authors" as |episode|}}
            {{#foreach episode}}
            <item>
                <title>{{title}}</title>
                <link>{{url absolute="true"}}</link>
                <pubDate>{{date format="ddd, DD MMM YYYY HH:mm:ss ZZ"}}</pubDate>
                <guid isPermaLink="false">{{id}}</guid>
                <category><![CDATA[ {{primary_tag.name}} ]]></category>
                <description>{{custom_excerpt}}</description>
                <content:encoded><![CDATA[ {{content}} ]]></content:encoded>
                <enclosure url="{{og_description}}" length="0" type="audio/mpeg"/>
                <itunes:subtitle>{{custom_excerpt}}</itunes:subtitle>
                <itunes:summary><![CDATA[ {{content}} ]]></itunes:summary>
            </item>
            {{/foreach}}
        {{/get}}
    </channel>
</rss>

You can copy and paste this exact implementation for your site, then go ahead and customize it to suit your needs! There are a couple of static variables which need to be adjusted, like your name, email, and iTunes category.

There’s also one very small hack/workaround that makes all of this work. The feed requires that you specify the podcast mp3/audio file URL for each episode. Because Ghost doesn’t have custom fields, we can repurpose the Facebook Description field for each post to store the link to the audio file. So wherever you upload your audio, just paste the provided URL into the Facebook Description and you should be all set.

Update routes.yaml and your active theme

Once you’re happy with your work, upload and update your active theme in Ghost Admin to enable your new RSS feed. Visit the feed at /podcast/rss/ to ensure it’s working as desired and submit it to iTunes 🎹

Summary

In this tutorial, you created a custom route and template to add a podcast RSS feed for iTunes and other podcast platforms to your Ghost site. Your podcast is now ready for the limelight!

If you're looking for other podcast tips and tricks when it comes to Ghost, check out the official Ghost podcasting theme, Wave, or come on over to our Forum, where creators and developers chat about all things Ghost.

On this page Introduction

How was the tutorial?

Be the first to know.

Join the Ghost developer community — sign up to get early access to the latest features, developer tools, and tutorials.

No spam. Once a month. Unsubscribe any time.