0

i wish to add a rel=nofollow in all links from an rss feed, including links in item description

$rss = new DOMDocument();
$rss->load($xml);
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
    $item = array ( 
        'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
        'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
        'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
        'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
        );
    array_push($feed, $item);
}
$limit = count($feed);

for($x=0;$x<$limit;$x++) {
    $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
    $link = $feed[$x]['link'];
    $description = $feed[$x]['desc'];
    $date = date('l F d, Y', strtotime($feed[$x]['date']));
    echo '<p><strong><a rel="nofollow" href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
    echo '<small><em>Posted on '.$date.'</em></small></p>';
    echo '<p>'.$description.'</p>';
}
  • What is the idea behind this? – MrWhite Apr 20 '15 at 7:19
  • What is your acctual question? – tillinberlin Apr 20 '15 at 10:47
1

RSS does not allow for nofollow. RSS is not HTML but a simple mark-up for Really Simple Syndication.

The documentation for RSS 2.0 can be found here: http://validator.w3.org/feed/docs/rss2.html It will contain much of the latest information you need.

1

I do like creativity but, I'm afraid the idea just doesn't make sense to me.

When you set up an RSS feed, you want the links to actually point to your site, not apply a nofollow to them. Also, links that have nofollow applied will cause search engine robots not to scan them and if the resulting pages are very high quality with advertisements in your name, then you'll likely lose out on income.

Think of an RSS feed as a special version of a site map. If there are links you want to hide, then you shouldn't have the script include those links in the first place.

  • All points I should have made. Excellent! BTW- nofollow does not equate to noindex. If Google finds the page via some other means and there is no noindex, Google will index the page. Nofollow is sometimes confused this way. – closetnoc Apr 20 '15 at 4:14
  • IMHO RSS feeds can be so much more than a site map or a newsfeed – what if you 'just' want to disribute information – but have no corresponding pages for the content? I can personally not think of a situation where this would make much sence – but still – why not? – tillinberlin Apr 20 '15 at 10:51
0

The only links that could take rel='nofollow' are ones within the CDATA in the body of the syndicated content. A quick and dirty hack would be to do a string replace for <a with <a rel='nofollow' when outputting the content of the articles. If they already have nofollow somewhere then you are going to make some ugly HTML.

As others have pointed out RSS specs do not allow for microformats like nofollow. Additionally you are depriving yourself of some solid SEO.

0

This may not always be positive SEO. If your source RSS contains link anchors that do not relate to your site content, Google cannot differentiate between those anchors and the links elsewhere on the page. This will cause a negative effect from an SEO perspective. Some people wish to have nofollows in all their RSS feed links - in fact WordPress RSS (and other CMS too) defaults to all nofollow links.

The difficulty is that many people do not have control over the formation of feeds they display because they come from a 3rd party; a solution for creating nofollows across a complete feed is actually in demand - I know this because I am support manager for the FeedWind RSS widget. We have been asked by users how to implement nofollow across a feed. So far the only solution we have identified is to create code that will parse feed content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.