« 10 Reasons MT 4 Will Rock Your Blog | Main | Why I like using the Extended field »

Creating a Continue Reading Link for Partial Feeds

The default Atom feed that ships with Movable Type is a full feed. It publishes your entire blog entry, not just the Main Entry Body or an excerpt. Although many people prefer full feeds, sometimes using a partial feed (publishing just part of the entry in the feed) is appropriate. For example, if your blog is commercial and your business model depends on getting readers to your site where they can view ads, then you might want to publish a partial feed, giving feed readers enough content to be interested to click through to your site. Also, if you publish a partial feed, feed aggregators and content slurpers will be less able to lift your content in its entirety. A key benefit to including a "Continue Reading 'Name of Entry'" link in your partial feed, is that when feed aggregators pick up and republish your content, it will include a link with SEO-friendly anchor text back to your site.

To turn your full Atom feed into a partial feed, all you have to do is remove one line of code from the feed template. Towards the bottom of the template where it says:

    <content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
        <$MTEntryBody encode_xml="1" convert_breaks="0"$>
        <$MTEntryMore encode_xml="1" convert_breaks="0"$>

Remove this line:

<$MTEntryMore encode_xml="1" convert_breaks="0"$>

and save and publish your template. This will produce a partial feed, with the Entry Body as the part of the content that gets published to your feed.

The next step is to add a "Continue reading NAME OF ENTRY" link, so that in your readers' feed reader program they can see that there is more content if they click through.

To add a Continue Reading link, there are two places on the feed template where new code needs to be inserted.

On the summary line which reads like so:

 <summary><$MTEntryExcerpt remove_html="1" encode_xml="1"$></summary>

It should read:

<summary><$MTEntryExcerpt remove_html="1" encode_xml="1"$><MTEntryIfExtended><![CDATA[<p><a href="<$MTEntryPermalink$>">Continue reading...</a></p>]]></MTEntryIfExtended></summary>

The other place is in the content section.

Where your content section is now:

    <content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
        <$MTEntryBody encode_xml="1" convert_breaks="0"$>

It should now read:

    <content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
        <$MTEntryBody encode_xml="1" convert_breaks="0"$>
<MTEntryIfExtended><![CDATA[<p class="extended"><a href="<$MTEntryPermalink$>">Continue reading "<$MTEntryTitle encode_xml="1"$>" »</a></p>]]></MTEntryIfExtended>   

Save and republish your template.

Please note that the good people of Feedburner helped me figure all of this out. I personally have no idea how or why this works. It is however the method I'm currently using with my Simply Recipes feed. I have not yet tested it with MT4, though I cannot see a reason why it wouldn't work in MT4. ~Elise

Comments (4)

It should work fine in any version of MT - and in fact, the basics of the technique should work fine for any RSS template (not just Atom), though the specifics may vary somewhat, since the details will vary a bit on what surrounds what you are doing.

The only difference in MT4 is that you could use the new tag syntax (for instance, mt:entrybody vs. MTEntryBody) - but other than that, the logic is sound, and you don't have to use the new syntax, as the old one should work fine.

As to what is happening, you are simply removing the actual text (the MTEntryMore tag itself), and you are replacing it with the permalink tag, that provides a link to the entry - but only if there is more content there - otherwise you are showing the entire entry, which is contained in the entry body.

After all, no sense showing "continue reading" if you've already read everything!

The CDATA bit is required to encapsulate the content, but you probably don't want me to get into that. :)

Any idea how to do this with the RSS2.0 feed?

Hi kimonstereo -

Locate this line (which currently includes the entire entry body):

<description><$MTEntryBody encode_xml="1" convert_breaks="0"$></description>

And replace it with this:

<description><$MTEntryExcerpt remove_html="1" encode_xml="1"$><![CDATA[<p><a href="<$MTEntryPermalink$>">Continue reading...</a>]]>

In other words, it's exactly the same as with the Atom feed, but instead of "summary", you're updating "description".

However, in the RSS template, you don't have a content section. It doesn't handle both - so you're done!

I struggled with this one for a while and finally figured out what I was doing wrong. Chad's code is correct but it's missing a few things.

The correct code for RSS2.0 feeds is :

<description><$MTEntryBody encode_xml="1"$><MTEntryIfExtended><![CDATA[<p><a href="<$MTEntryPermalink$>">Continue reading...</a></p>]]></MTEntryIfExtended></description>

Post a comment

(If you haven't left a comment here before, your comment may need to be approved before will appear on the entry. Thanks for waiting.)