Thursday 20 February 2014

schema for blogger

This tutorial was made for Blogspot blogs, but you should be just fine following along and getting your blog marked up if you aren't using Blogger.

Articles

In your template, find the element that wraps your post content. To find it faster, do a search for <data:post.title/>. It might be an article or div element with the class post hentry. We need to tell search engines that this is a blog post using microdata.
<article itemscope='' itemtype='http://schema.org/BlogPosting'>
The itemtype attribute value I'm using is for regular blog posts. If your blog is made up mostly of different types of articles, such as news articles or any other kind, I think you should use the generic itemtype attribute value for articles:
<article itemscope='' itemtype='http://schema.org/Article'>

Headline

The next thing we markup is the post title. I have applied two attribute values, name and headline, to my title element because they both apply, but you can just use name.
<h1 itemprop='name headline'>
  <data:post.title/>
</h1>

Body

Next up is the body of the post. In your template, search for the div element that is wrapped around <data:post.body/>. Add itemprop='articleBody' to it; like this:
<div class='entry-content post-body' itemprop='articleBody'>
  <data:post.body/>
</div>

Description

<p itemprop="description">Cats were made for memes like women were made for men.</p>
This lets you use any paragraph in your article as the description that appears when users share your content with the Google+ button.


Image

<img itemprop="image" alt="Hersheys milk chocolate bar and milkshake combo" src="the-goods.png" title="Oh, my taste buds!"/>
This lets you use any image in your article as the image that appears when users share your content with the Google+ button.

Author

Find the code used to display the post's author: <:data:post.author/>. I tell search engines who is the author by adding rel='author' to the author profile link.
<a expr:href='data:post.authorProfileUrl' rel='author'>
  <data:post.author/>
</a>
It's not microdata, but you can use it in place of it and everything will be fine. If you prefer to use microdata, here is what you do:
<span itemprop='author' itemscope='' itemtype='http://schema.org/Person'>
  <a expr:href='post.authorProfileUrl' itemprop='url'>
    <span itemprop='name'>
      <data:post.author/>
    </span>
  </a>
</span>

Keywords and Tags

Find the code that renders the post's labels(tags/keywords). We are going to wrap each label within span tags that will have itemprop='keywords'. Depending on your template, there might be two conditions in which a label is printed.
<b:loop values='data:post.labels' var='label'>
  <b:if cond='data:label.isLast != "true"'>
    <a class='tag' expr:href='data:label.url'>
      <span itemprop='keywords'>
        <data:label.name/>
      </span>
    </a>,
  <b:else/>
    <a class='tag' expr:href='data:label.url'>
      <span itemprop='keywords'>
        <data:label.name/>
      </span>
    </a>
  </b:if>
</b:loop>
The first condition checks to see if the label it is printing is not the last one. If it isn't, then that label will have a comma to separate it from the rest. If your template has that condition, you need to add the span tags twice exactly like it did.

No comments:

Post a Comment