Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add atom:link with rel="self" to an rss document?

Tags:

rss

I am trying to create a dead simple rss feed. I validate my rss using this service form w3.org. Here is what my feed looks like:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>example.com RSS</title>
        <link>https://www.example.com/</link>
        <description>A cool website</description>
        <item>
            <title>Cool Article</title>
            <link>https://www.example.com/cool-article</link>
            <guid>https://www.example.com/cool-article</guid>
            <pubDate>Sun, 10 Dec 2017 05:00:00 GMT</pubDate>
            <description>My cool article description</description>
        </item>
    </channel>
</rss>

but I get this error from the feed validator:

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

line 14, column 4: Missing atom:link with rel="self" [help]

So I click on [help] and get this:

If you haven't already done so, declare the Atom namespace at the top of your feed, thus:

Then insert a atom:link to your feed in the channel section. Below is an example to get you started. Be sure to replace the value of the href attribute with the URL of your feed.

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

Okay, first off I was trying to validate rss, not Atom but they seem to be trying to steer me in the direction of Atom. Okay, I'll try it anyhow.

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>example.com RSS</title>
        <link>https://www.example.com/</link>
        <description>A cool website</description>
        <atom:link href="http://www.example.com/rss.xml" rel="self" type="application/rss+xml" />
        <item>
            <title>Cool Article</title>
            <link>https://www.example.com/cool-article</link>
            <guid>https://www.example.com/cool-article</guid>
            <pubDate>Sun, 10 Dec 2017 05:00:00 GMT</pubDate>
            <description>My cool article description</description>
        </item>
    </channel>
</rss>

Validate that and it gives you this error:

Self reference doesn't match document location [help]

So I click on [help] and get this:

Check the document referenced by the href attribute. If it is not the intended feed, correct it.

This may not be a problem. At the current time, the feedvalidator does not probe to assess equivalence of documents.

And that's where I'm stuck. They don't say how to get it to do that. Do I get it to do that by reading the atom specification and reimplementing my feed as Atom? Because I am not going to do that.

like image 288
user875234 Avatar asked Jan 07 '18 14:01

user875234


People also ask

How do I add atom links to my RSS reader?

When the RSS reader is installed and you click on ATOM link in Easy Redmine, the following window (or similar) opens, showing you the button " Subscribe " to the RSS feed, and the link that you can copy and insert into your RSS reader directly (this is helpful when the button is missing or doesn't work) as illustrated below.

Why am I getting 'missing atom link with REL=self'?

When you submit an RSS feed to the Feed Validator that doesn't contain the element, you get the warning message "Missing atom:link with rel='self'." This doesn't prevent the feed from being valid, but it has irked some people who expected their feed to pass with no warnings.

What is the URL of an RSS feed?

According to the RSS Advisory Board 's Best Practices Profile, identifying a feed's URL within the feed makes it more portable, self-contained, and easier to cache. For these reasons, a feed should contain an atom:link used for this purpose.

What is an example of a link rel?

Example: <link rel="help" href="/help/"> Imports an icon to represent the document. Specifies that the browser should preemptively connect to the target resource's origin.


1 Answers

You don't have to turn your feed from RSS to Atom to support atom:link.

To fix the problem, in the atom:link element, change the value of the href attribute to the URL of your RSS feed. So if your RSS feed is at http://dallas.example.com/rss.xml, the atom:link element should be this:

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

Including an atom:link element in your RSS feed makes it more portable and easier to cache. For more details, visit the RSS Best Practices Profile.

like image 90
rcade Avatar answered Sep 22 '22 07:09

rcade