RSS Feed ExplainedGuest Post by David Zimmerman: Google likes fresh content. I think most SEOs know this. I’ve even heard of SEOs who regularly change their home page’s content to give the Google spider a reason to come back to their website for a crawl, once in awhile.

Surely there’s an easier way to do this. Something automated that partners with what you’re already doing would be great. Something you could install on a page once and the content would be constantly changing would be even better.

Hmmm… sounds like a call for an RSS feed.

If we could take an RSS feed and display it on our website, every time that feed changed the webpage would have some new content on it. This would then give the Google a reason to come by for a regular visit.

The problem is that many widgets people use to embed an RSS feed are not SEO friendly. Most RSS widgets take a feed and display it using JavaScript.

Sure, Google is doing a better job of crawling JavaScript lately but why do we want to make it difficult for our visitor to see what’s new on our webpage? We need a server-side script that can easily take an RSS feed and display it as the page is rendered.

We need to use XSLT (short for , “Extensible Stylesheet Language Transformations”- say that five times real fast and you’ll realize why developers abbreviate it). This takes any XML formatted data and converts it into another format. In this case we want to take an RSS feed (which is a form of XML) and transform it into HTML (which is yet another form of XML).

Now, some of your eyes just glazed over and your have been stunned by the alphabet soup of abbreviations I’ve just thrown at you. Don’t be intimidated– you just need two files to implement this in PHP. If you don’t get it, just take this post and give it to your developer and they’ll take good care of you.

File 1: the XSL stylesheet

Copy the following code and save it as “rss2html.xsl”:

<?xml version=”1.0″ encoding=”UTF-8″?>

<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”>

<xsl:output method=’html’ encoding=”UTF-8″ />

<xsl:template match=”rss/channel”>

<ul>

<xsl:for-each select=”item[position() &lt; 6]”>

<li><xsl:value-of select=”description[1]” disable-output-escaping=”yes” /><br />

<span style=”font-size:smaller;”><em><xsl:value-of select=”pubDate[1]”/></em></span></li>

</xsl:for-each>

</ul>

</xsl:template>

</xsl:stylesheet>

This is the file used to convert HTML into RSS. In this case it takes the description from the first 5 items in an RSS feed and displays it in an unordered list (<ul>..</ul>) along with the published date (which happens to be in a smaller font, in italics. If you can overcome your coding fears you will be able to see the HTML used in this XSL stylesheet (and even customize it according to your needs).

 

In order to connect the RSS feed we’re going to supply and display it in the final HTML form, we need some PHP code (you can do this in about every other programming language, if you need to, but I know PHP).

 

File 2: the PHP code

You can either copy the following code and save it as a .php file (to include anywhere you want to display the feed) or just copy this code straight into your PHP document:

<?

// create a DOM document and load the XSL stylesheet

$xsl = new DomDocument;

$xsl->load(“/rss2html.xsl”);

// import the XSL styelsheet into the XSLT process

$xsltProcessor = new XsltProcessor();

$xsltProcessor->importStylesheet($xsl);

// create a DOM document and load the XML

$xmlDoc = new DomDocument;

$xmlDoc->load(“http://feedtwit.com/f/dizzyseo”);

try {

echo $xsltProcessor->transformToXML($xmlDoc);

} catch(Exception $pEx) {

echo $pEx->getMessage();

}

?>

Even someone with some basic PHP skills should be able to understand this code.

  1. We’re creating a new DomDocument object that contains our XSL file (which we called, “rss2xml.xsl”).
  2. Then we import the XSL file into a XsltProcessor object.
  3. From there create another DomDocument into which we import the RSS feed we want to display.
  4. After that we display the feed which, thanks to our XSL document, has been nicely formatted into an HTML unordered list.

It’s just that easy!

Now that we have a way to display an RSS feed on our site, in an SEO-friendly way, we just need to decide which feed to display. In this case I’m displaying an RSS feed from my Twitter account, @dizzySEO. I think Twitter is an ideal RSS feed to display on pages for a freshness boost:

  • You’re already using Twitter, so you can now harness this effort to keep your web page fresh
  • Twitter accounts are often updated very frequently
  • When you update your Twitter account with relevant information from your business, you are not only displaying fresh but also relevant content on your webpage
  • It shows you’re active on Twitter and encourages them to engage you

Unfortunately Twitter stopped providing the RSS feed from each Twitter account in June 2013. That’s why I’m using a service which creates a Twitter RSS feed from your Twitter account called FeedTwit (full-disclosure: I created this service). You can create an RSS feed for your Twitter account by signing up too- because I’m cool, like that.

But why go to all this trouble? Why not just use Twitter’s own widget to embed your tweets on your webpage? Because Google can’t crawl that content, since they use JavaScript to display your tweets using their widget, which means you’ll miss out on page freshness you’ve been looking for.

About the Author: David Zimmerman

When David Zimmerman is not creating cool services like FeedTwit, he is working as a full-time SEO or hiking in the mountains of North Carolina.

 

Pin It on Pinterest

Shares