Working on my most recent side project, I’ve had to brush up on my Blogger/Blogspot coding. One of the things requested of me was to find a way to have a static front page on a Blogger site.
WordPress has this feature built-in, but Blogger currently does not. :wallbash_tb:
I know of two ways that this can be accomplished:
Solution #1
Create a new post with the content you want to show on the index of your Blogger site and save as normal. When you add more content to your site, re-open your “front page” post. Click Post Options. Change the Post date and time to values which chronologically fall after those of your last “regular” post.
Now go to Settings, Formatting. Set it to show only 1 post on the main page.
The idea is to always keep the “front page” post as the newest, so it is the top post (and therefore the only one shown on the main page). You’ll have to do this every time you add new posts to your Blogger site.
Or …
Solution #2
I like to call this one the “Sticky Content method.”
A while back someone had shown me that enabling the showaddelement
attribute in a Blogger XML template allowed you to add widgets above your posts. Basically, changing a small bit of code in your template …
… gave you this ability:
I’ve seen plenty of people do this to display Google Ads or other PPC stuff above their posts.
To do this, you’ll need to first download a fresh copy of your template — go to Layout, Edit HTML, Download Full Template.
Open it in your text editor of choice (use Notepad if you’re not sure) and search for type='Blog'
or “posts”. Either of those should show you the section code containing the Blogger function for calling blog posts. You’ll see a line that says something along the lines of:
<b:section class='main' id='main' showaddelement='no'>
When you change showaddelement
from ‘no’ to ‘yes’, you are then able to add widgets above your blog posts. Save the changes to your XML and upload it to Blogger (go to Layout, Edit HTML) using their upload form. Once that’s done, go add a widget by going to Page Elements (in Layout).
Click Add a Gadget, and add the HTML/JavaScript widget and type in the content you want to show on your front page and save.
Keep in mind: that this would show up on EVERY page on your site unless you adjust a couple things!
Download an updated copy of your template and open it in your text editor of choice. Now that you’ve added a widget, you should see something like this:
Hint: Look for the title of your widget if you get lost!
Change the following:
<div class='widget-content'>
<data:content/>
</div>
to this:
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<div class='widget-content'>
<data:content/>
</div>
</b:if>
Basically, you are telling Blogger to only display that widget if the page you’re on is the home page (main page).
Now, let’s fix the blog settings so that nothing shows up on the main page except this widget. Go to Settings, Formatting, and set it to show no posts on the main page.
Pretty cool, huh? :)
Closing Thoughts
Whichever method you choose, make sure that you have some way for your visitors to access your site’s content. I suggest adding Blog Archive and Labels widgets. You could also use the Feed widget and put in your RSS feed to show your blog’s latest posts.
I hope the solutions I’ve posted are clear, but if you need anything explained further please feel free to ask in the comments below!
Rick
Solution #3: Convince client they’re much better off with WordPress.
Rick´s last blog post: Do You Flickr?
Nicki
LOL, if I could have, I would have. The client wanted more control over the template than WordPress.com accounts give, and they did not want to pay for hosting for a “proper” blog (self-hosted WP). Their mind was already made up on what they wanted, and the site was already established on Blogger. :P
Leoney
Hi Nicki, Great tips. I will try on my blog. Thanks.
Leoney´s last blog post: The Basics On How TO Start Making Money With Adsense
shane
I tried this and I am told:
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The element type “b:if” must be terminated by the matching end-tag “”.
I replaced with the following:
any ideas?
Nicki
Hi Shane, could you please post your code on PasteBin so we can see it? Thanks!
shane
nicki-
I have posted my code at pastebin.
Thank you for your help?
-shane
shane
I am having one hell of a time posting messages here, and I fear it is making me look like a moron. My first message left out an important piece of info and I didn’t realize until about 10 minutes later so I posted my second message to rectify that situation but in doing so didn’t notice you asking me to post my stuff to pastebin making it seem like I was ignoring you. Finally when thanking you I included a question mark as though maybe on my part I wasn’t sure if you were helping me or not. All this ridiculousness in one day!!
so to clarify…Thank you for your help Nicki!
-shane
Nicki
Hi Shane, what’s the link to it? ;)
shane
http://shanehood.pastebin.com/me5c3845
shane
I tried scheme 2 that is and got the above error message.
Nicki
Shane, again, could you please post your code on PasteBin so we can see it? Thanks!
Nicki
Shane,
I found and downloaded the original copy of this theme and am looking at it now. Yours seems to have several changes. Do you have a copy of the last working version of this? (before you started changes?)
I’m not sure at which point you are/were when the error messages appeared.
shane
the only changes i have made are in regards to the navigation tabs labeled home, gallery, news, forum, history.
the page worked fine up until I tried to enter the piece of code that would show the widget only on the front page.
the piece of code to introduce the widget above the post section worked fine.
Nicki
Hi Shane, can you post the last working version of this template? Thanks!
shane
well thats complicated, the template works right now as i have it set up, its just the bit of code to prevent the widget from appearing on all pages that prevents it from working. i will post what i have currently as it currently works.
shane
http://pastebin.com/m2bfef503
shane
got it…thanks for your help
shane´s last blog post:
Nicki
You got it working? Good to hear. :)
Elaine Heirigs
Thanks for this tip! I really like how it creates the best of both worlds, blog and website. I do miss my self hosted wordpress but with your tweeks and others I have created at site with a custom URL for only 10 bucks. Plus buying through blogger makes it so easy to use google mail with this domain. Thanks again!
Nicki
Hi Elaine, you’re most welcome! :)