How to summarise posts in serendipity rss feeds

By default serendipity places the entire entry body in your rss feeds but not the extended body. If you’re like me you rarely use the extended body when making entries so your feed subscribers can read your entire posts without having to visit your site. This defeats the entire purpose of RSS feeds that are supposed to increase traffic to your site. Furthermore there are a lot of scraper sites out there that use your rss feeds to duplicate your site’s content. A lot of these rightly link back to your site but they still put your site in danger of Google’s so called duplicate content penalty. Supposedly google can’t tell which site was the originator of the content and may penalise the wrong site. So what is an s9y blogger to do? Well hack serendipity of course!

Actually its quite easy. Every feed has its own .tpl file. .tpl files are the basis for templates in serendipity. The idea is that templates contain only those .tpl files that are unique to them. All other .tpl files are read from the default template folder. So to make a global change that persists regardless of which template you use you will need to edit the feed .tpl files stored in the templates/default folder.

Lets start with rss 2.0. To change the length of each post as it appears in your rss 2.0 feed you will need to open templates/default/feed_2.0.tpl file and search for this:

{$entry.feed_body|@escape}

To make a summary of 250 characters you would replace the above with this:

{$entry.feed_body|@strip_tags|@truncate:250:false}

Each rss version has its own .tpl file and you can follow this same process for all of them.

In the case of the two Atom feeds defined in feed_atom0.3.tpl and feed_atom1.0.tpl you will need to search for this:

{$entry.feed_body}

And replace it with this:

{$entry.feed_body|@strip_tags|@truncate:250:false}

Now mind you there is one downside to this code modification. Since all html tags are removed from these post summaries, none of the images in your post will show up in your rss feeds even if they are placed at the beginning of your post.

You can download the full set of modified serendipity post summary feed .tpl files for use in your blog. Just unzip and upload them to the templates/default folder of your site.

One thought on “How to summarise posts in serendipity rss feeds

  1. Readers may wish to refer to part one of my summary posts in serendipity blog feeds guide.

    After reading a blog post about the need to specify meaningful summaries of posts for rss and atom feeds I decided to take another look at post summarising i

Leave a Reply to Abdussamad's blogspace Cancel reply

Your email address will not be published. Required fields are marked *