How to display latest feeds from a blog on a static HTML page ?

Written on September 27, 2007 – 3:34 pm | by aditya |

So here comes something damn interesting. Yesterday , my friend Vaibhav asked me a question (any perhaps many other people in past too), how do i display latest feeds from a blog on my site. Site be a dynamic PHP site or a static HTML site. (Example :- See this site displaying my feeds on all its pages on the sidebar :) )Things are easier when your files are with PHP extension and many guys do it too right now, but a very few people know how to actually do in on a HTML site. Some people suggested me to use javascript to pull, parse and display RSS feeds but again the problem with this is that, for people like me whole blood is filled with SEO stuff hate javascript. We need static direct HTML links.

Okay so now lets get to the real thing. We need to display links from a RSS feed on our website. The RSS feed might be coming from anywhere like a blog on the same domain or a blog on another domain. Now we need to open the feed (which is generally in XML format), parse it and convert it to HTML according to a template and display it on our site. This has a bit of functionality and functionality cannot be implemented without coding. So we need to do some PHP stuff. If your site is made on PHP files, then this can be implemented easily, but in case of static HTML there is a simple trick which can be used. Some guys from http://www.feedforall.com have created a simple script to read RSS (in XML format) and convert into HTML format. Now in order to simplify some things, i have made a few modifications to their script and have it for download here. (Note:- Original credits and copyright still goes to Feed4All. Great Script they made).

Now if your site is a HTML site, a simple directive in the .htaccess will instruct the Apache server to parse HTML files for PHP code and execute it. So open your .htaccess file and add the following lines to it -

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Okay, now half of the stuff is done. Download the file rss2html.zip and unzip it. It consists of two files rss2html.php and template.html. Open rss2html.php and edit it with notepad. On the top part of the file you will see some lines like -

$XMLfilename = “http://www.adityaspeaks.com/feed/”;
$TEMPLATEfilename = “template.html”;
$FeedMaxItems = 5;

This is what you need to edit. Set $XMLfilename to the feed you want to display and $FeedMaxItems to the number of items which you need to display. No need to edit the second line. Upload both the files rss2html.php and template.html to your site.

Now all you need to do is place 1 line of code whereever you want the feeds to appear on your site (You can now place PHP stuff in HTML files too) -

<?php include ‘rss2html.php’; ?>

You are Done !

Now you can control the look of how feeds are displayed using the template.html. The file is pretty self explanatory and will not require any rocket science to edit it :)

Did you like the post ? Subscribe to our feeds
Enter your email address:


  1. 8 Responses to “How to display latest feeds from a blog on a static HTML page ?”

  2. By Amit on Sep 27, 2007 | Reply

    Excellent job there, let me implement it somewhere now ;)

  3. By RedHat39 on Sep 28, 2007 | Reply

    By George, I believe you’ve got it!

    This sounds just crazy enough to work.

    Seriously though. If this does work I have lots of uses for this kind of “web magic.”

  4. By Amit on Sep 29, 2007 | Reply

    Its not working

    After adding the following code to htaccess -
    RemoveHandler .html .htm
    AddType application/x-httpd-php .php .htm .html
    I get
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator

    Tried both 644 and 666 permission to the newly made htaccess file since the older website didnt have any htaccess because its a pure html based site.

    Any samples where you did this?

  5. By aditya on Sep 29, 2007 | Reply

    Sample is in the post itself http://www.amishapatelworld.info. Worked very well man

  6. By Stasigr on Oct 29, 2007 | Reply

    Hello, very nice site, keep up good job!
    Admin good, very good.

  7. By Las Vegas Guy on Nov 7, 2007 | Reply

    I’m going to give it a go. I’m using Drupal so the site is based on PHP. Nice tutorial.

  8. By Kristion on Nov 11, 2007 | Reply

    Cool…

  9. By Jyves on Apr 10, 2008 | Reply

    Wow, just what I was looking for. I’ll give it a try this weekend! I see that you’re using those adverts which automatically turn some words into commercial hyperlinks. Do you know how it would be possible to recreate that effect, so that a particular word is automatically highlighted and linked to a particular section of a website? For instance, everytime the word “tomato” appears on my website, it is turned into a hyperlink to my tomato page? Thanks :-)

Post a Comment

My Profile at Various Sites and Forums

Digg | StumbleUpon | Del.Icio.Us | Sphinn | FaceBook | MyBlogLog | Reddit | SlashDot | Netscape / Propeller

Digitalpoint | SEOMoz | SearchEngineWatch | v7n Forums | SitePoint | NamePros | WebTalkForums

Enter your email address:




Add to Google Reader or Homepage
Subscribe in NewsGator Online
Add to netvibesAdd to My AOL
Subscribe in BloglinesPowered by FeedBurner



StumbleUpon



Find entries :