Blogger Classic Templates Bugs and XHTML

Updated on Sunday, May 3, 2020
I've just migrated this blog from catfood.net to its own domain. In the process I needed to port the template from classic ASP to ASP.NET and I also wanted to end up with valid XHTML.

If you're using blogger on your own domain then you're using the classic templates. There is a known issue with the template tag that causes Blogger to emit unwanted JavaScript - this causes havoc, especially if you're using the tag in the section of a page.

Google recommends using the <$blogpagetitle$> tag in the page title. This works, but it's not great from a usability or SEO perspective. For item pages you get the post title after the blog name and you probably want to put the post title first - the earlier that keywords appear in the title the better for search engine ranking.

Luckily there's an easy fix - just comment out the closing Blogger tag:

This doesn't interfere with the template rendering correctly and the JavaScript is then commented out on the rendered page. It's still an unpleasant bug, so if you use the classic templates please report it here and also star or comment on this forum topic to encourage Google to fix it.

If you use labels then Blogger includes them in a paragraph rendered with <$blogitembody$>. This means that wrapping <$blogitembody$> in a paragraph will cause XHTML validation errors for posts with labels because you can't nest another block element inside the paragraph.

The other XHMTL nasty I fixed was the post comments link. My template used the recommended Blogger code:
p>a href="$BlogItemCommentCreate$>"
$BlogItemCommentFormOnClick$>>Post a Commenta>p>

This renders as:
p>a href="https://www.blogger.com/comment.g?blogID=12345678&postID=1234567890123456789"
location.href=https://www.blogger.com/comment.g?blogID=12345678&postID=1234567890123456789;>
Post a Commenta>p>
And you end up with a gazillion cascading XHTML errors, all caused by the illegal ampersand. I fixed this by constructing my own comment URL using the <$blogitemnumber$> tag (this emits the unique Post ID):
p>a href="https://www.blogger.com/comment.g?blogID=12345678&postID=$BlogItemNumber$>">
Post a Commenta>p>

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Blogger Classic Templates Bugs and XHTML #code #ithcwy How to solve Blogger Classic Templates Bugs and XHTML )

Comments

Santina

Ditto above. Thank you!

Add Comment

All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.

Newsletter

Related

Party Limits