How Do You Add Atom - Link With Rel - Self - To An Rss Document - Stack Overflow

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

 

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


Asked
4 years ago Active
1 month ago Viewed
12k times

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:
11
<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0">

<channel>

<title>example.com RSS</title>

1 <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>

Join Stack Overflow to learn, share RSS</title>

<title>example.com knowledge, and build your career. Sign up


<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.

rss

Share Improve this question Follow asked Jan 7 '18 at 14:43


user875234
2,099 5 26 41

Oddly, <atom:link is still giving me issues with the validator: validator.w3.org/feed/… . Even with the
implementation of most of the suggestions below! (High-voted question with no high-voted answers,
eerie situation indeed!)
– HoldOffHunger
Dec 19 '21 at 1:54

5 Answers Active Oldest Votes

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

5 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
Join Stack shouldtobe
Overflow this:share knowledge, and build your career.
learn, Sign up
<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.

Share Improve this answer Follow answered Jan 7 '18 at 15:59


rcade
196 10

1 Strange that this was downvoted. It is perfectly valid:


validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html
– Sjeiti
Aug 31 '19 at 19:59

@Sjeiti Returns invalid when you actually run that .html in the actual W3.org Atom validator. (Your
link is only to the docs page.)
– HoldOffHunger
Dec 19 '21 at 1:52

As the message says the feed is valid. So you can proceed without making any changes to the
feed. None of my feeds have that link and they work perfectly well. The message is very old
3 and not accurate.

Share Improve this answer Follow answered Jan 7 '18 at 15:15


Dave Winer
1,851 1 17 13

The validator is often wrong or confusing. I was generating an Atom document recently and
attempted to check with that tool, it started to advice me about missing tags from RSS... Get
3 rid of the atom:link tag that was suggested by the tool, it's for Atom document not RSS. I
would just double check with RSS specification instead of using the tool.

Self reference doesn't match document location [help]

It's probably checking against Atom specification again. Even if it was a valid Atom document,
if you were pasting the xml content into the tool, you will get that message. It checks whether
whether the 'self' link in atom is same as the location the atom document is being served from.

Share Improve this answer Follow answered Jan 11 '18 at 1:09


Robert C. Holland
1,475 17 47

There are great answers here already, and I'd guess that Dave Winer's answer is authoritative,
but for those of us who'd like to eliminate validation errors wherever possible…
2
This is
Join Stack likely a case
Overflow of mismatched
to learn, scheme
share knowledge, - in
and thisyour
build example,
career.the feed was likely requested
Sign up at
https://www.example.com/rss.xml, but atom:link specifies that the feed is to be found at
http://www.example.com/rss.xml.

Note http vs https :

<link>https://www.example.com/</link>

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


/>

Share Improve this answer Follow answered Aug 24 '21 at 7:02


ptim
13.2k 9 75 92

This one took me some time!

0 <atom10:link

xmlns:atom10="http://www.w3.org/2005/Atom"

rel="self"

type="application/rss+xml"

href="https://example.com/news.rss"

/>

The error message is not very informative when it tells you to add a <atom:link> , because it
should be telling you to add an <atom10:link> .

Here is a demo of it at work: W3C Validator.

Share Improve this answer Follow answered Dec 19 '21 at 16:08


HoldOffHunger
14.1k 8 71 110

Join Stack Overflow to learn, share knowledge, and build your career. Sign up

You might also like