Saturday, July 25, 2009

HOWTO: Add a Read More Option

Update:
Please follow this better Read More option, instead of the one described here.

If your blog contains long posts and you want to only show a selected snippet of each post on your homepage, here’s a simple method to add a “Read More” option to hide part of a post on the homepage (and also on archive pages).

  • Go to Layout -> Edit HTML and click the ‘Expand Widget Templates’ check-box.
  • Then locate the </head> tag and add the code shown in red in the following snippet, above that tag.
]]></b:skin>
<style><b:if cond='data:blog.pageType == "item"'>
span.fullpost {display:inline;}
<b:else/>
span.fullpost {display:none;}
</b:if></style>

</head>

  • Then locate the <data:post.body/> element and add the code shown in red below.
<div class='post-body entry-content'>
<p><data:post.body/>
<b:if cond='data:blog.pageType != "item"'><br/>
<a expr:href='data:post.url'>Read More</a>
</b:if>

</p>

  • Then for each post that you want to display a summary, you have to add the following piece of code enclosing the part that you want to hide. (Do this from the Edit Html tab of the post editor)
This is a sample long post. Only these two lines are visible on the homepage.
<span class="fullpost">This sentence, which is enclosed inside the HTML code
shown in red, will be displayed only when a visitor clicks on the Read More
link.</span>



Reference:
Expandable Post Summaries

5 comments:

Chiew said...

Hi...thanks for the tip.
Just one problem, though. The 'read more' seems to appear in all posts! Any way around this?
http://acliltoclimb.blogspot.com

Sadashiva Bhat said...

hi.. thanks for read more option... :-)

http://bhatshiva.blogspot.com

ids said...

@ Chiew,

See this tip on the Blogger help forum for a different method to add the "Read More" link, only for the posts you want.

Parminder Singh Jawanda said...

how can i change the color of the post

Mark said...

Very useful article. Soon I will try to add read more option to my blog.
In my opinion you are in top blogs about blogger. In last year total on your blog there is 30386 visitors.
I believe that your blog can do more. My advice is to read article : Increase blogger traffic - change title. This method helped my blog visits to growth more than 40% in one month.

Post a Comment

Thanks in advance for all your comments and suggestions. They are very much appreciated.

IMPORTANT:
If you have a specific technical question, please email me with a description of the problem and the blog's URL.