The hCard microformat is used to make contact information machine readable. In BlogEngine.NET 1.4.5 this is being supported in the post comments. However, if you are writing your own custom theme, you need to add a little bit of code to your CommentView.ascx theme file.

The themes bundled in BlogEngine.NET 1.4.5 already have these small pieces of code embedded, so let’s take a look at the Standard theme’s CommentView.ascx file.

The containing <div> now have two classes: vcard and comment. The vcard class is new and is the one that triggers the hCard microformat. It looks like this:

<div id="id_<%=Comment.Id %>" class="vcard comment...

If the vcard class is added, machines will expect to find an hCard microformat within that <div>, but we need to add one more class to make it a valid hCard – the fn class name.

In the Standard theme’s CommentView.ascx file you can see where the name of the comment author is written. If it author supplied her website URL an hyperlink is created, otherwise a span tag. The hyperlink has a class attribute with two class names: fn and url. This tells the hCard crawlers that this is both the full name and the URL of the contact. In the span, only the fn class name is needed.

So, if you want to support microformats in your custom themes; take a look at the Standard theme’s CommentView.ascx file and make the appropriate modifications. BlogEngine.NET 1.4.5 already adds the appropriate classes to the avatar image and country flag, so you don’t have to do anything there.


Amr Elsehemy

Web Semantics are extra cool and the fact that BlogEngine.NET support them is awesome keep on the good job BE is the best.

Amr Elsehemy

Comments are closed