How to write an atom feed ?

2022-06-15T14:31:10Z

ATOM feeds let one subscribe to your website and get latest content. It is free. It can be used to publish content.

ATOM is RSS improved.

Instead of relying on provate social networks, you should consider using feeds.

Let's see how to write an ATOM feed.

First, insert a header :

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/atom.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>https://si3t.ch/log/</id>
  <title>log de prx</title>
  <icon>/favicon.svg</icon>
  <link rel="alternate" type="text/gemini" href="gemini://si3t.ch/log/"/>
  <link rel="alternate" type="text/html" href="https://si3t.ch/log/"/>
  <link rel="self" type="application/atom+xml" href="https://si3t.ch/log/atom.xml"/>
  <author>
    <name>prx</name>
    <email>prx@si3t.ch</email>
  </author>
  <updated>2022-06-08T15:55:32Z</updated>

As you can see, the two first line are xml declaration, the 2nd call a stylesheet to display the atom feed. It is optional.

Then, we open a tag "<feed>".

id should be unique, use an URL as example.

You should specify linksto tell where is the content (alternate) and where the feed actually is (self) in case of redirections. Add an author section if you want.

Finally, insert a date when your feed has been updated. It has to be modified each time you update your feed. Format is <year>-<month>-<day>T<hour>:<minutes>:<seconds>Z.

Then, you can add entries : they are your content. 1 entry = 1 article. Add as many as you want.

<entry>
    <title type="text">Youtube to mpd</title>
    <id>gemini://si3t.ch/log/2022-06-06-yt2mpd.gmi</id>
    <updated>2022-06-06T14:57:30Z</updated>
    <link rel="alternate" type="text/gemini" href="gemini://si3t.ch/log/2022-06-06-yt2mpd.gmi"/>
    <content type="text"><![CDATA[
	Some stuff...
	Your article...
]]></content>
  </entry>

As you can see, you can write some metadata :

To end an entry :

Finally, close your feed since it must be XML valid content.

</feed>

That's it 😉

See also

About feeds.

What is Atom ?

atom.awk to generate an atom feed (http)

atom.awk to generate an atom feed (gemini)