Microformats – a way to display more content in the search engines
The article below is targeting more advanced users, who have some knowledge in HTML and preferably in PHP. We expect that you have knowledge on Joomla! plugin system and template overwrites. Otherwise, it will be very hard for you to figure out how to do it.
Have you ever seen a result in Google, looking like this?
Or maybe one like the one below?
Well, many of you maybe want to display additional data in the search results, like we are able to do in the two examples below. However, this needs some additional tuning of your web site. Not very hard one, but still basic knowledge of HTML is required.
That’s what we are going to talk about in this article. Basically the topic is of using microdata to display extended information in search engines or the so called “Rich Snippets”.
Introduction
Microformats or microdata are set of properties attached to standard html tags, which enable the search engines to recognize that specific data is certain type of data. For example: recipe, hotel, restaurant etc. These are attached to the HTML tags and search engines understand that for example the number 3 in your HTML is in fact the number of reviews you have for the hotel.
There are various types of item properties that are available, but probably reviews, ratings and recipes are the most common type that you see in the search engines on a daily basis. We are going to come back on the types of a bit latter, but what you can display as Rich Snippet depends a lot from the item property type (or content type) that you have.
How to implement in Joomla?
The bad news
Joomla! doesn’t offer a lot of chances to have different content types, because there is no easy built-in way to add additional fields to the content, or to format it in different ways in general. However, there is still a solution. You may use the Content templater extension from nonumber.nl to create predefined templates that have microdata support. It becomes more complicated if you want to add reviews, but you may decide to use the excellent plugin that has the built-in functions and available from 3D Web Design (note: it is commercial, we are not affiliated with them).
You can use the 3D Web Design plugin only and it will support ratings, however it doesn’t support more deep data such as recipes, or similar.
If you rely on Content templater, the issue would be, that there is no easy way to manage the process in case you have user submitted content. You will need to edit each item to add the necessary microdata tags as it is not very probable that the users would be able to add it themselves.
The good news
The good news is that there is a way to predefine all the fields and data you need. However, you need to use the K2 extension for that purpose (used also here in the Joomla! Community Magazine). It has the ability to render additional plugins (custom made/developed) with extra fields as you wish. It is not that hard, and they have a nice example plugin for that as a start. The other huge advantage of K2, is that you can have basically different types of predefined sub-templates for each content type, so one site could easily have restaurants, hotels, recipes and other types.
How to do it with K2?
Create sub-template overwrites for each content type you want to display. This is done by copying components/com_k2/templates/default content into templates/YOURSITETEMPLATE/html/com_k2/restaurants (you may use whatever you want instead of restaurants).
Now edit the file item.php which is in that folder, by following the guidelines referred to below to add the necessary item properties to the image, rating etc. We usually use the main K2 div to wrap the whole microdata details and then specify what is what on each sub-property (rating, image etc.). You may look at our Review template source code as a reference on how it was done.
Additional data
Create your own plugin to have extra fields like for example cooking time or ingredients for recipes. Take the K2 example plugin as a reference and starting point. When echoing the content, add where applicable the necessary sub-item properties. For example, echo a list of all ingredients by stating for each list item that this is ingredient.
Item types, item properties
There are various item types and we may list them here, however all of them could be found on the common project by Bing, Yahoo and Google for microdata: http://schema.org
Here is a list of the currently supported content types: http://schema.org/docs/schemas.html and when clicking on each, you may find the necessary item properties that you need to add to your HTML. Some of the major items include: events, recipes, place, local business, aggregate offer, product etc.
As we are currently working on a recipe template and plugin for K2, we would recommend you to start with it, as it has good example: http://schema.org/Recipe
Want more?
If you are interested in implementing microformats in your web site, we are open to provide help (i.e. answer of reasonable questions) free of charge in our forum.
Notes
Google and other search engines do not guarantee that your site will be displayed with Rich Snippet, even if your code supports it.
It takes time for a web site to be indexed with rich snippets. Our experiments show that sometimes it takes about 6-9 months.
Some articles published on the Joomla Community Magazine represent the personal opinion or experience of the Author on the specific topic and might not be aligned to the official position of the Joomla Project
By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/
Comments