XML error on swapping blog and post title on new blogger - feureau.com

www.feureau.com
inner sanctum . cgi/art . comic . digital movies . forum

Friday, December 21, 2007

XML error on swapping blog and post title on new blogger

UPDATE: This hack is no longer valid as you will not be able to add it to your blogger template.

When you search for a post in a blog, say, with google, does the search result shows the title of the post? Or the name of the blog? If you say the latter, which is the default condition for blogger, then you'll need to swap the blog title and the post title on your blog.

Jacky Supit, on his blog, posted New way to swap Blog Title and Post Title on New Blogger.

What is this, exactly? To put it simply, it's turning this:
Before
Into this:
After
Now why would anyone try to do that? One might wonder. It doesn't seem to worth the effort. However, this little change can mean a lot. Putting the title of the post before your website title means that when people search for something and google returns your site, the title of the page presented to the user will not start with the title of your site. Which in my case would mean, because of the title's length, it'll take up most of the space available on google search to show the title of the page, like so:
A Bad search result.
Which means that the user would less likely to click on it because they don't see the title of the page representing the topic they'd want to see. Not only this is SEO, this is just common sense.

Now, to remedy this, you'll need to swap the titles. To do that, you'll just need go to your blogger dashboard, go to template > edit html. You will then need to select expand widget template, and then look for:

<title><data:blog.pagetitle/></title>

Like so:

That single line is the only thing you'll need to replace. However, the hack to achive our purpose, is not that simple. The code is provided on Jack Supit's blog post, however, some users (like me) has reported that it returns an XML error, like so:
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: Open quote is expected for attribute “{1}” associated with an element type “cond”.
So, after a bit of investigating, the code apparently contains some minor bugs. I think it's due to blogger's habit on changing punctuation marks. A little tweaking, and I managed to get the code to work on this blog. Here's the code that I end up using.
<b:if cond='data:blog.pageType == "item"'>
<b:section id='swaptitle'>
<b:widget id='Blog2' locked='false' title='Blog Posts' type='Blog'>
<b:includable id='nextprev'/>
<b:includable id='backlinks' var='post'/>
<b:includable id='post' var='post'>
<title>
<data:post.title/> - <data:blog.title/>
</title>
</b:includable>
<b:includable id='commentDeleteIcon' var='comment'/>
<b:includable id='status-message'/>
<b:includable id='feedLinks'/>
<b:includable id='backlinkDeleteIcon' var='backlink'/>
<b:includable id='feedLinksBody' var='links'/>
<b:includable id='postQuickEdit' var='post'/>
<b:includable id='comments' var='post'/>
<b:includable id='main' var='top'>
<b:loop values='data:posts' var='post'>
<b:include data='post' name='post'/>
</b:loop>
</b:includable>
</b:widget>
</b:section>
<b:else/><title><data:blog.pageTitle/></title>
</b:if>
If, somehow blogger decides to change some marks, here's a txt file of the code that you can download.

After that, just save the template and go see if it works.
The title hack only changes the titles of post pages, and not your main page.


8 comments:

Andrew Z said...

For some reason, I am getting error bX-erahav

http://groups.google.com/group/blogger-help-troubleshoot/browse_thread/thread/03c442070a8cee22/ca30008ef01f7853#ca30008ef01f7853

Feureau said...

Looking at the discussion thread, I don't think that error is caused by swapping blog title. It's probably a hiccup in blogger's system. I've been getting some errors myself when changing my template a bit this last couple of days. Try clearing your browser's cache wait for some times, then reapply the codes. The error stopped happening on my blog after that.

Tip: Before you apply the template, save your edited templates to a text editor like notepad so you won't have to redo everything in case of error.

Milan said...

I have not gone through the code in this post, as the code is lengthy. But, this trick really works. I am getting top 10 ranking for "make money reading book"
Read detail explanation at

Swap blog title for post

In similar way you can also change the description of the post, which is explained at Swap title description for post

Andrew Z said...

The Blogspot error went away, and it just works now. Thanks! :)

Mike Monahan said...

This works, but SEO wise it removes the title data from the pages.

For instance when using http://www.submitexpress.com/analyzer/

if you look at the pages with this swap you will see there is no title tag.

Is there a way to edit the code to fix this?

Thanks,

Mike

Feureau said...

That tool seems to analyze a title meta tag of the page, and not the title of the html page, which is what google use on its search.

I seem to have lost a meta title tag on my page after all the overhaul last month. That is easily addable by using a meta tag and a title description.

This code does not touch any of the meta tag, so it won't have any effect on submitexpress' meta analyzer.
What this hack does is just to automatically switch the post title and the blog title on the post pages so it would appear as post title first then the host name. It affects only the <title></title> part and not the meta tags.

Mike Monahan said...

Thanks. I feel a little better that Google doesn't use it for search but I would still like to have it in there.

But when I do use this hack it takes out the meta page title. It was up there before the hack. (I do have a backup of my blog but I still want to see how my pages rank with this addition.)

Can you point me to any resources as to where I can regain the "meta title tag" for my individual pages.

I noticed jackbook.com has individual page titles but I can't find any info on how they did that.

Thanks,

Mike

Kim Hjortholm said...

An updated and somewhat simplified version of the hack can do the swap trick again - check my post at http://edgecrafting.blogspot.com/2008/03/swap-blog-title-and-post-title-on.html

***

about meta tags ..... they mean close to zero with respect to SEO, anyone can put anything in them, so the don't really carry any importance anymore