On this page:
1.1 Step 1:   Mint a tag URI
1.2 Step 2:   Create a list of items
1.3 Step 3:   Create your feed
1.4 Step 4:   Generate the XML for your feed
1.5 Wrap up
8.9

1 Quick start

There are four simple steps to building a feed with this library:

1.1 Step 1: Mint a tag URI

Every feed needs a globally unique identifier, and this library requires you to use tag URIs for this purpose. To mint a tag URI, you provide three things: a domain (or an email address); a date, and a specific identifier:

> (define my-id (mint-tag-uri "example.com" "2012" "blog"))

The idiomatic route is to create a tag URI for the entire feed, and then append to that URI to create tag URIs for the individual items in that feed.

See Tag URIs for more information.

1.2 Step 2: Create a list of items

You’ll generally want to write a function that converts your item data from its original format into feed-items, and then create your list by mapping that function over each of the items.

For this tutorial, we’ll manually make a list with just one feed-item in it:

> (define my-items
    (list
     (feed-item
      (append-specific my-id "first-post")         ; item-specific ID
      "https://example.com/first-post.html"        ; URL
      "Chaucer, Rabelais and Balzac"               ; title
      (person "Marian Paroo" "marian@example.com") ; author
      (infer-moment "1912-06-21")                  ; publish date
      (infer-moment "1912-06-21")                  ; updated date
      '(article (p "My first post; content TK")))))

1.3 Step 3: Create your feed

The feed struct combines all the elements we’ve created so far:

> (define my-feed
    (feed
     my-id                     ; tag URI
     "http://example.com/blog" ; site URL
     "River City Library Blog" ; Title
     my-items))

1.4 Step 4: Generate the XML for your feed

Final step: pass your feed to express-xml, specifying either the 'atom or 'rss format, and provide a URL where the feed itself will be accessible:

> (display (express-xml my-feed 'atom "https://example.com/feed.atom"))

<?xml version="1.0" encoding="UTF-8"?>

<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">

  <title type="text">River City Library Blog</title>

  <link rel="self" href="https://example.com/feed.atom" />

  <link rel="alternate" href="http://example.com/blog" />

  <updated>1912-06-21T00:00:00-06:00</updated>

  <id>tag:example.com,2012:blog</id>

  <generator uri="https://racket-lang.org" version="8.9">Racket v8.9 [cs] + splitflap v1.2</generator>

  <entry>

    <title type="text">Chaucer, Rabelais and Balzac</title>

    <link rel="alternate" href="https://example.com/first-post.html" />

    <updated>1912-06-21T00:00:00-06:00</updated>

    <published>1912-06-21T00:00:00-06:00</published>

    <author>

      <name>Marian Paroo</name>

      <email>marian@example.com</email>

    </author>

    <id>tag:example.com,2012:blog.first-post</id>

    <content type="html">&lt;article&gt;&lt;p&gt;My first post; content TK&lt;/p&gt;&lt;/article&gt;</content>

  </entry>

</feed>

There you go! Save that string in a file and you’ve got yourself a valid Atom 1.0 feed.

Let’s do one in RSS format, for kicks. Note the different URL for this version of the feed:

> (display (express-xml my-feed 'rss "https://example.com/feed.rss"))

<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">

  <channel>

    <title>River City Library Blog</title>

    <atom:link rel="self" href="https://example.com/feed.rss" type="application/rss+xml" />

    <link>http://example.com/blog</link>

    <pubDate>Fri, 21 Jun 1912 00:00:00 -0600</pubDate>

    <lastBuildDate>Fri, 21 Jun 1912 00:00:00 -0600</lastBuildDate>

    <generator>Racket v8.9 [cs] + splitflap v1.2 (https://racket-lang.org)</generator>

    <description>River City Library Blog</description>

    <language>en</language>

    <item>

      <title>Chaucer, Rabelais and Balzac</title>

      <link>https://example.com/first-post.html</link>

      <pubDate>Fri, 21 Jun 1912 00:00:00 -0600</pubDate>

      <author>marian@example.com (Marian Paroo)</author>

      <guid isPermaLink="false">tag:example.com,2012:blog.first-post</guid>

      <description>&lt;article&gt;&lt;p&gt;My first post; content TK&lt;/p&gt;&lt;/article&gt;</description>

    </item>

  </channel>

</rss>

If you want the result as an X-expression, you can do that too, using the #:as keyword argument:

> (express-xml my-feed 'rss "https://example.com/feed.rss" #:as 'xexpr)

'(rss

  ((version "2.0") (xmlns:atom "http://www.w3.org/2005/Atom"))

  (channel

   (title "River City Library Blog")

   (atom:link

    ((rel "self")

     (href "https://example.com/feed.rss")

     (type "application/rss+xml")))

   (link "http://example.com/blog")

   (pubDate "Fri, 21 Jun 1912 00:00:00 -0600")

   (lastBuildDate "Fri, 21 Jun 1912 00:00:00 -0600")

   (generator "Racket v8.9 [cs] + splitflap v1.2 (https://racket-lang.org)")

   (description "River City Library Blog")

   (language "en")

   (item

    (title "Chaucer, Rabelais and Balzac")

    (link "https://example.com/first-post.html")

    (pubDate "Fri, 21 Jun 1912 00:00:00 -0600")

    (author "marian@example.com (Marian Paroo)")

    (guid ((isPermaLink "false")) "tag:example.com,2012:blog.first-post")

    (description "<article><p>My first post; content TK</p></article>"))))

1.5 Wrap up

Now you know how to use this library to create a feed for your website.

To create a podcast feed, just use episode instead of feed-item, and podcast instead of feed. Check out the module reference for details of using those functions.