Post Summary And Read More

My old friends here are very well aware of the Peek-A-Boo-Posts hack that Ramani and I came up with several years ago. It required quite some template hacking and javascript too.

In this tutorial you will learn how to tweak your blog without any javascript to get a similar effect. On our homepage, all posts will show a short summary, followed by a "Read More" link. Clicking the "Read More"-link will bring up the post page with the full post text.

Step 1: Back up your template
Open the Layout|Edit HTML-tab on your Dashboard, and download the template as an XML-file to your harddisk. If anything goes wrong, upload it again and there will be no problem at all.

Step 2: Modify the template code
Scroll down and look for the following piece of code:
<div class='post-body entry-content'>
<data:post.body/>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>

This is the piece of template code that displays the post-body on the screen. We have to add a few lines of code here:
<div class='post-body entry-content'>
<b:if cond='data:blog.homepageUrl == data:blog.url'>
<style type='text/css'>.restofpost {display:none;}</style>
</b:if>

<data:post.body/>
<b:if cond='data:post.link'>
<a expr:href='data:post.link'>Read more...</a>
<b:else/>
<b:if cond='data:post.url'>
<a expr:href='data:post.url'>Read more...</a>
</b:if>
</b:if>

<div style='clear: both;'/> <!-- clear for photos floats -->
</div>

Now save your template.

Step 3: Modify your post template
In your Blog Settings you can modify the post template. Change it to:
<div class="summary">Type summary here</div>
<div class="restofpost">Type rest of post here</div>

And save your settings.
This will take care of all new posts. Type the summary text in between the summary-div-tags. Type the rest of the post between the other div-tags, and publish!

Step 4: Modify old posts
If you want older posts to have summaries as well, change every post and add a summary-div and restofpost-div.

And furthermore...
The summary-div is not really necessary, as the code only hides the restofpost-div if we are on the homepage. If you want some other styling for the summary, add CSS-tags to the skin-part of your blog.

This is what people say:

ArahMan7 said...

Hola Johann,

I see that your BeautifulBeta is having a new face-lift. It looked much more beautiful.

Congratulations Johann and,

Greetings and lots of love from Malaysia.

firdaus zahari a.k.a FaKE said...

added you to my blogroll here http://www.efzec.com/2009/03/link-exchange-with-efzeccom.html feel free to do the same =)

Jack Bede said...

'Post summary and read more' is a Wonderfully simple solution. Only problem is the words 'read more' appear after the expanded post. Can this be removed?

Lamer said...

Agree with Jack.

And another one issue. How to remove "read more" link from posts where I do not want to make expandable post? A lot of my posts are very short and I do not need to expand them.

Thank you.

YASH♣ROCKS said...

Hi this is YASWANTH ..Brother I ould not activate this ..
post the solution to roksolid.yash@gmail.com

oneasall.blogspot.com

Padimin said...

Thanks you for your tips.
I will try to do soon.

Andrei said...

"And another one issue. How to remove "read more" link from posts where I do not want to make expandable post? A lot of my posts are very short and I do not need to expand them."

I have the same question too...I hope Hans will clear this problem soon...

Brence said...

I am also getting the Read More link showing at the bottom of the full post. How do I get this to be hidden?

Gray voice said...

hi, i am giving my blog a makeover so i was thinking to introduce a border in my sidebars so that there can be a better look, right now i have done some changes and brought everything to gray background, i want only my sidebar background be gray and the main background be black, how can i do that or just introduce a border for better distinguishable profile??? hope u will be happy to help, i am not intelligent with html, but i work with trial and error method....http://greybrainbites.blogspot.com/
u can have a look and provide me with some more ideas, before i start afresh with my postings...

Brence said...

I have managed to FIX the problem with the "Read More..." link showing on the post page.

I have posted the solution on my blog here: http://simplerthanyouthink.blogspot.com/2009/04/blogger-expandable-post-summary.html

Now the Read more will only show on the summary.

janeywan said...

Hi Hans,

Sorry this is off topic, but not sure where to post the comment for a plea for help. Anyway long time ago I added a hack in comment section I honestly can't remember if it was called one click or what. I recently notice it now says "submit query" and leads one to an advertisement. I'd like to remove but not sure exactly what to remove. Before I go and really screw things up I'd though I'd ask for your guidance. Thanks

janeywan said...

Hi Hans,

I posted a previous comment. Please disregard, I've fixed it. It wasn't your hack. Sorry to bother you.

v-kostin said...

Thanks 2 Brence! Your trick really works!

kona~chan said...

What if my template doesn't have anything like the first codes in step 2?

I couldn't find it in my codes~

Gearu said...

kona~chan - you must tick the 'Expand Widget Templates' checkbox to show the code you are searching for.
I have blog post that will walk you through creating the blog summaries here as well, if that is of any help: http://simplerthanyouthink.blogspot.com/2009/04/blogger-expandable-post-summary.html

Ahsan Ali Mumtaz said...

Your blog is great.Nice article.hit+please visit my site
http://tinyurl.com/o9frav
have a good day.see you.

Kal's Studio said...

nice tutorial.. nice blog n great explanation.. keep it up..
http://kalstudio.blogspot.com/

Melgar said...

Nice trick there Brence, but I already featured out to remove the Read More.. in my full post before I have read your post. Thanks anyway.

The only problem is the Read More.. in short posts, but it seems it is impossible of doing that. Maybe it will be base on word count or letter count on the post itself but how to do that????? I have no clue??????

Rajesh Kumar.Chekuri said...

if some my posts very short then i don't want read more button then waht modification i need to
do..

www.funevil.blogspot.com

Sabihis said...

Articles that you write is very interesting, I keep this blog link in a list of favorite link in my blog http://www.Ads4Blog.co.cc And i will definitely visit again

Sherry said...

Could you please help me? I put a bookmark bar on the bottom of my posts and the address in the code is for this blog but i can not find your tutorial on it. The problem is i no longer want a bookmark bar and can not figure out how to remove it :(