Introduction to Microformats + a look at hCard & hAtom

September 28, 2006 | Published in: Web design & development | Tags: , , , , , 6


hAtom

hAtom is a microformat used for marking up blog posts/syndicated content.

hAtom is a draft microformat for content that can be syndicated, primarily but not exclusively weblog postings.

http://microformats.org/wiki/hAtom

If you use a blogging application, such as wordpress, hAtom is very easy to implement to your templates.

Marking-up hAtom

The properties of hAtom are show below, along with the part of the blog entry they apply to.

  • hfeed – Goes around all the posts on the blog page.
  • hentry – Contains an individual blog post.
  • entry-title – The title of the blog post.
  • entry-content – The content of the blog post.
  • entry-summary – Summery of the blog post, for example an excerpt.
  • updated – When the post was last updated.
  • published – Date the post was published.
  • author – Author of the entry, must be a hCard. If no author is present, the nearest
    with class ‘author’ (that is a hCard) will be used.
  • bookmark -For the permalink, uses rel-bookmark.

Using hAtom with the Wordpress loop

To make wordpress display your posts using hAtom you can add the hAtom class names to the wordpress loop. Here is an extract from a wordpress loop that I converted to use hAtom:

<div id="content" class="hfeed">
	<?php if (have_posts()) : ?>
		<?php while (have_posts()) : the_post(); ?>
			<div class="hentry entry" id="post-<?php the_ID(); ?>">
				<h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
				<small><abbr class="published" title="<?php the_time('Y-m-d'); ?>T<?php the_time('h:m:s'); ?>"><?php the_time('F j, Y'); ?></abbr></small>

				<div class="entry-content">
					<?php the_content('Read the rest of this entry &raquo;'); ?>
				</div>

				<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
			</div>

		<?php endwhile; ?>

With posts marked up as hAtom, the firefox ‘Tails’ extension can see them, this is a screenshot of Tails viewing Blue Anvil.

hAtom Screenshot

So that was a quick tour of hAtom. Although still in the draft stages, hAtom is set to be an extremely useful Microformat, and I look forward to its completion.

For more examples of hAtom go to the hAtom wiki examples page.

For more information on hAtom go to the hAtom wiki.

Closing Remarks

To conclude, I just have to say, I believe Microformats are a great thing, and the web as a whole will benefit from them in the future. The semantic benefits of using Microformats is extremely exciting, and I hope webmasters understand, and use them whenever possible.

I look forward to new and exciting Microformats, and cannot wait for them to be utilised by software and search engines.

Further Reading

Page: 1 2 3

Found this post useful? Why not buy me a coffee!

Related Entries

Popular Entries

6 Responses to “Introduction to Microformats + a look at hCard & hAtom”

RSS feed for comments on this post.

  • 1 - Anthony says: Reply to this comment

    Gravatar

    Great article that showcases some of the widest spread uses of Microformats, I’ll have myn up soon! Microformats is a word I found quite scary at first but the more you read about it the more you realise its possible widespread use.

    Comment made on February 9, 2007 at 6:07 pm

  • 2 - Dactura says: Reply to this comment

    Gravatar

    I have been reading about hCard for two days… two 8 hour days and your article is the best. Especially appreciate that you have taken the time to take the vCard and format it nicely with CSS to appear as a business card. Nice touch!

    I still have no idea how one prevents the spam-bots from harvesting all these vcards though! I do not think the mung will help; but I do believe the spam filters are getting much better.

    Comment made on February 9, 2007 at 6:08 pm

  • 3 - Mike J says: Reply to this comment

    Gravatar

    Thanks :)

    In regards to the spam bots, I know munging is not the perfect solution, but I havent had much problem with spam yet. There are other solutions out there, e.g javascript scripts for hiding mail, I personally havent tried them yet, but some could be effective (although no solution will ever be 100% effective).

    Any contact details on the web are always at risk from spam, its a shame, even forms get abused.

    Comment made on February 9, 2007 at 6:09 pm

  • 4 - Astorg says: Reply to this comment

    Gravatar

    This is the best article on hcards I have seen so far. I agree with oen earlier commenter, though, that spam can be a problem. He mung will not be enough since tests have shown that even a minged address that has never been used for anything else can get spammed. Could you suggest details of a javascript solution?

    Comment made on May 29, 2007 at 3:00 pm

  • 5 - The Lemonade Theme • Griffin & Hoxie says: Reply to this comment

    Gravatar

    [...] Jolley’s awesome introduction to using hcard and [...]

    Pingback made on March 28, 2008 at 7:44 pm

  • 6 - Healing the Body says: Reply to this comment

    Gravatar

    Don’t worry too much about spambots. You still have to eyeball your creations and allow a bit of time for manual editing.

    Comment made on June 19, 2008 at 1:49 pm

About this site

Blue Anvil is the online web design journal & portfolio of , a web designer from Norfolk, England. Read More »
ThemeSlice
  • Featured work - More

    • Beefjack
    • Integrity
    • theotaku.com
    • Manic Melon
  • Latest Tweet - More

    • Dropped yoghurt all down my pyjamas. Bugger. Working in my boxers. Ill get dressed some time. Soon.
  • Out of the blue - More

    • Wordpress 2.8 Memory Usage

      With the release of wordpress 2.8 some people are experiencing out of memory php errors along the lines of:

      Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 228968 bytes)

      You may also be seeing pages fail to load fully (for example the wordpress admin dashboard) if php error messages are hidden. I’ve already had one case where we thought certain plugins were to blame but in fact it was just out of memory. A possible fix (which worked in the previously mentioned case) is to add:

      @ini_set('memory_limit','64M');

      to your wp-config file. Has anyone else encoutered this error?

    • jQuery Curvy Corners 1.x and 2.x updated and moved to Google Code

      I have updated the jQuery Curvy Corners plugins (both versions) with jQuery 1.3.2 support and other enhancements. The beta 2 version is looking good and is working in all version of IE, Opera, and Firefox (as far as I can tell).

      You can grab the latest files from Google Code here. Enjoy.

    • I’m too nice: Wordpress Download Monitor plugin page add-on now included with Download Monitor version 3.1.

      It was going to be a paid add-on, but today I had a change of heart and bundled it with the newest version of download monitor. The add-on lets you make a download page using a shortcode; it lists your downloads/categories with full sorting, pagination, and search functionality. Not bad eh? See the documentation topic to see full instructions for usage, or see my download page to see it in action.

      And if you use it, please consider making a donation to ensure the continued development of the plugin!

    • 2 Announcements: New Support forum, and feedback wanted for new download page add-on

      First, I’ve implemented a support forum to Blue Anvil mainly for plugin support and ideas which can be found here. Hopefully this will make supporting my plugins easier. Feel free to add to the discussions (there is also a general web design forum too).

      Secondly, I’ve added a demo of the new download page add-on I’m making for Download Monitor. This will be a paid add-on and it would be cool to get any feedback or suggestions from anyone who would like such a feature. My download page is here. Please leave feedback on the forum or in the comments.