The ability to display extracts of posts is a feature which many of us would love to see added to Blogger! Such a feature would prevent readers having to scroll far down the page to find the next post on home and archive pages, and in many cases, could offer the potential for different styles of layout...
Many Blogger users have adopted Ramani's selective expandable posts hack or a similar alternative. However, I have found these to be a little complicated: they require manual editing of each post or cause other irritating problems. In my search for an elegant and less cumbersome alternative, I have discovered an almost perfect solution: the jQuery Expander Plugin by Karl Swedberg.
Integrating the jQuery Expander plugin for Blogger offers many useful options and features:
To see how well the jQuery expander plugin could work in Blogger, take a look at this demonstration in which the posts expand into the same page. Installation
Depending on the style of post summaries you would prefer to display, the method for installation will be slightly different.
I'll begin with a default explanation which will summarize posts with a link to expand in the same page (this requires only two steps). Next we can make two small changes which prevent expansion and add a link to the post page.
Finally I'll explain how you can alter some options for extracts which can be applied to both methods.
For whichever function you prefer, the installation is simple and the result will be elegant post summaries for your Blogger powered blog :)Method 1: Expandable post summaries
This is the simplest method to add excerpt functionality to your blogger powered blog!
Firstly, go to Layout>Edit HTML in your Blogger dashboard and check the "expand widget templates" box.
Then, find the closing tag in your blog template, and paste the following section of code immediately before it:
Next, find this section of code (or similar) in your template:
If you cannot easily find this section, search for the following tag using your browser's search function:
You need to highlight this and any surrounding code, as in this screenshot:
Replace this section of code with the following instead:
Now preview your template. You should now notice that posts on your home page have been summarized and feature an ellipsis at the point of truncation which (once viewed in the live page) is a link to expand/truncate the post:
If you're happy with this, you can save your template and enjoy using your new post summaries right away. Alternatively, read on for methods of preventing the expansion in the same page, and customizing the excerpts to suit your preferences.Method 2: Excerpts with a link to the post page
My personal preference is to display only an excerpt of posts with a link to the full article. This requires only two small changes to the default installation:
Assuming you have already added the codes from Method 1, here is what you should do:
1. Find this line in the section of your template:
And replace it with this instead:
I have highlighted the different file name in bold red so you can see the change at a glance.
2. Next, find the code you have added around the
Be careful to add this in the correct place, just above the
Continue Reading
tag, otherwise it will not be displayed!
Now preview your template. The "linked" ellipsis should now be replaced with a plain one, and you should see the "Continue reading" link appear beneath the extract. You could change the link text to anything you prefer (eg: "Read more", "Full Post", etc). Then proceed to save your template.Post Summary Options
The jQuery plugins used for these methods are almost identical, except that the "extracts" version has the "more" link removed.
Both plugins therefore have identical options which you can set by adding or changing code in your blog template.
The options can be configured within the internal javascript in the head section which by default appears like this:
Here are some of the most used options available, and how they can be changed. A full list of options can be found on the expander plugin for jQuery page.
You can add or change any of the lines above as appropriate for your needs.License, Credits and Download
This function uses the jQuery JavaScript library and the jQuery expander plugin for the base functions.
The Expander Plugin for jQuery was created by Karl Swedberg and is dual licensed under the MIT and GPL licenses.
If you would prefer to host the jQuery scripts on your own server, you can download a zipped folder including all scripts from this tutorial and a basic Minima template in which this function has been added for demonstration or testing purposes. As in the case of the original Expander Plugin and jQuery file, these are provided under the GPL licence.
Download Elegant Blogger Post Summaries Files
I hope you have found this tutorial to be a useful and elegant solution for creating and using post summaries for your Blogger template. Please feel free to leave your comments and any suggestions for improvement below.
Elegant Post Summaries for Blogger with jQuery
Posted by SoMeOnE at 1:48 AM Labels: Customize your Blogger Template
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment