Learn to customize your own blog with confidence

Code it Pretty is an archive of tutorials from 2012-2015. Tutorial details may be outdated. More Info

Showing posts with label metadata. Show all posts
Showing posts with label metadata. Show all posts

Recipe Rich Pins for Blogger

Recipe Rich Pins for Blogger

Starting in the spring of 2015, some of my readers have not been able to successfully validate their blogs for Recipe pins using the markup from this tutorial. It seems that Pinterest may have changed some of the requirements, but hasn't updated the documentation for Recipe Rich Pins yet. Since the documentation hasn't changed I don't know what is different about the Recipe validation process. I'll keep an eye on the documentation to see if updates become available.

It can't hurt your blog to add this markup — it's recognized by other search engines, too — but it may not get you validated for Recipe Rich Pins.

I'm a total foodie, so I'm excited to share a little something special for food bloggers today! In this post I'm going to show you how to enable recipe Rich Pins for Pinterest on your Blogger blog.

If you haven't seen them yet, Rich Pins are Pins with a bit of extra information on them — for recipes, you can add ingredients, instructions, cooking times, and more.

We'll use hRecipe markup to enable Rich Pins in recipe posts. You can use this markup to turn any recipe on your blog into a Rich Pin-able recipe, even if you're not exclusively a food blogger!

I'm going to show you how to write the markup "by hand" first, then share a few free online tools to help you write your markup faster.

Ready to get started? Let's do it!

Markup For Your Template

The majority of the Rich Pins markup goes into individual posts, but I'm going to save you a little work by giving you one line of code to add directly to your template.

First, back up your template (instructions here). Do not skip the backup.

Next, open up your template by clicking the "Edit HTML" button below your "Live on Blog" screenshot. Find the <head> tag near the top of your template code (it's usually in the first 10 lines).

Immediately below the <head> tag, enter this meta tag:

<meta property="og:site_name" content="YOUR SITE NAME HERE" />

Replace "YOUR SITE NAME HERE" with the name of your blog. You can do that as a title (for example, "Code it Pretty") or as your blog's URL (for example, "www.codeitpretty.com").

Next, press the orange "Save template" button to save your updated template.

Marking Up Your First Recipe

I'm going to show you how to completely mark up a recipe to make a fully detailed Rich Pin, but you should know that Pinterest only requires you to mark up two parts of your post for Rich Pins: the title of the recipe and at least some of the ingredients.

If you want to leave a little "mystery" to entice Pinterest users to click through to your post, you can just mark up the title and key ingredients. Nothing else is required.

For best results, start with a recipe that has already been published on your blog, and has also already been Pinned to Pinterest. Also, if you don't already have a favicon for your blog, add one! It will show up on Rich Pins from your blog.

Switch to the HTML Editor

Open up a post you'd like to make Rich Pin-nable and switch to the HTML editor by clicking the HTML button at the upper right of your post editor. The HTML button turns a slightly darker grey when it's selected.

Wrap Your Recipe

Pinterest needs a signal to know your post includes a recipe, so we're going to wrap the recipe portion of your post with an HTML element called a div.

Find your recipe in the body of your post and add this line right above the recipe's title:

<div class="hrecipe">

Then, find the end of the recipe, and add a closing </div> tag below the last line of the recipe:

</div>

That closing </div> tag is super important. If you leave it off, your sidebar will get pushed to the bottom of the page, so don't forget it!

Next: Mark Up Your Recipe Title

Find your recipe's title in the body of your post. Add this line right before the first word of your recipe's title:

<span class="fn">

Then, add a closing </span> tag at the end of the title, like this:

<span class="fn"> Orange-Pineapple-Carrot Smoothie </span>

Again, the closing tag is important, so don't leave it out.

Next: Mark Up Ingredients

You don't have to mark up all of your ingredients, but it's helpful if you include the major stuff. Each ingredient needs to be marked up individually with the class "ingredient".

Wrap a <span> tag around each ingredient with a class of "ingredient", like this:

<span class="ingredient">3/4 cup chopped fresh pineapple </span>

Repeat the process for each ingredient you want to mark up.

If you wrote your ingredient list as an ordered or unordered list, you can insert class="ingredient" into the opening list item tags for your ingredients instead, like this:

<li class="ingredient">3/4 cup chopped fresh pineapple </li>

The effect is the same as adding a span tag, it just saves you some time!

Optional Markup

Yield

You can indicate your recipe's total number of servings using the "yield" class, like this:

<span class="yield">Serves 1</span>
Cook Time, Prep Time, and Duration

You can indicate cooking time, preparation time, and the total time it will take to make your recipe. Here are example of how to indicate each:

Cook Time

<span class="cookTime"><span class="value-title" title="10M"> </span>10 minutes</span>

Prep Time

<span class="prepTime"><span class="value-title" title="10M"> </span>10 minutes</span>

Duration (prep and cook time combined)

<span class="duration"><span class="value-title" title="10M"> </span>10 minutes</span>

To change the time markup to match your recipe, change "title" value to the correct amount of time. Minutes are indicated with a capital M, hours are indicated with a capital H.

Re-Publish Your Post

When you're all marked up and ready to publish, press the orange "Publish" button up top. Your published post will look normal to your readers — the little bits of markup we added around your recipe won't be visible in the published post. But, if you view your page source you'll see everything you just added to the post.

Test Your Recipe Markup and Submit to Pinterest

Now you're ready to test your Rich Pins! Before you test, though, you should know that the Pinterest validator is flaky. Your first recipe may not pass — one of my tests failed even though I was using Pinterest's own demo markup. If your first URL doesn't validate, try again with another post. As long as you're using the correct markup, you should be able to pass validation after a few tries. Here's how to get validated:

  • Go to the Rich Pins Validator on Pinterest's developers site and submit the link to your post with rich pin markup — not your home page.
  • If your URL fails, don't get discouraged. Mark up another recipe and submit that one, making sure to include the recipe name and ingredients markup. It can take a few tries before the validator recognizes your markup, even if it is correctly formatted.
  • When your URL passes, you'll be prompted to apply for Rich Pins. Click the "Apply Now" link to continue.
  • On the next screen, check the "website domain" field. If you have a .blogspot.com URL, you'll need to correct the URL to your blog's actual address (for example, codeitpretty.blogspot.com).
  • Set the "Data Format" radio button to "HTML Tags" and press the red "Apply Now" button.

After you apply, you'll see a preview of how your Rich Pins will look. The screenshot below was provided by Olivia Morrissey from Not A Plain Jayne, one of the early testers of this tutorial.

rich pins preview screenshot

Pinterest takes a few days to approve blogs for Rich Pins, and will notify you by email when you are approved. Olivia got her approval notification in 4 days.

Recipe Markup Tools

If you need a little help speeding up the process, there are two free online tools you can use to generate your markup.

RecipeSEO.com is an online recipe builder that generates hRecipe markup for you.

If you use the Chrome browser, you can use the hRecipe Helper extension.

Image in title card CC-BY Flickr user ilovebutter.

Twitter Cards for Blogger

This post is outdated. Twitter cards and Blogger have both changed since this was posted in 2012. I recommend this tutorial from my friends at Blogger Xpertise for current Twitter card markup.

Have you noticed lately that some Tweets have a little something extra? Like my Tweets, for example?

These "expandable" Tweets are enhanced with the new Twitter Cards. Twitter Cards show more detail about your posts to give readers a little preview of what they'll see when they click your link. And, the cards work when anyone Tweets a link to your post — not just you. So, if someone else Tweets a link to your blog post, their Tweet will have all the preview details, too!

Today I'm going to share the exact markup I used and the steps I took to get Twitter Cards working for me on Blogger.

Before we get started, there are a few things you should know about Twitter Cards:

There are Three Types of Twitter Cards

In this tutorial I'm going to focus on making a summary card. Summary cards show the title of your blog post, a thumbnail image, a short description of your post, and your Twitter handle. The other two card types — photo and player — are not included in this tutorial, but you can learn more about them from the official Twitter Cards documentation.

Twitter Cards are a New Feature

Twitter added this feature in June, so it's still quite new. Like most new things, these cards are a little quirky. Not everyone will see the cards all of the time or on every browser/mobile platform. Twitter knows this and they're working on it.

They Don't Work Instantly

You have to add the Twitter cards markup to your template, then submit your blog to Twitter for acceptance. After you submit your blog you'll have to wait an unspecified period of time until the cards activate. Some people get an email from Twitter when their cards start working, others don't. I didn't; I just happened to notice that my cards were working about 2 weeks after I submitted my application.

Note: The Dynamic Views template behaves unpredictably if you alter its meta tags. If you'd like to use Twitter cards for your blog, choose a different Blogger template.

As long as you're cool with those caveats, we can get into how to set up Twitter Cards on Blogger!

Step One: Get Your Blog Posts Ready for Twitter Cards

Twitter Cards use your post's Search Description as your summary, so you'll want to make sure that you've filled it in on each post. I posted an in-depth tutorial on how to enable and use the Search Description feature in this post: All About Blogger Search Features.

Step Two: Back Up Your Template

Do not skip this step. You're going to add the Twitter Cards markup directly to your template, so before we do anything else you need to back that template up! Go to "Template" and click the "Backup/Restore" button in the upper right corner. On the next screen, click "Download full template" and save the .xml file. If anything goes wrong while you're adding the Twitter Cards markup you can restore your blog with your backup file.

Step Three: Add the Twitter Cards Markup

Now that you've backed up your template (you did that, right?), click the "Edit HTML" button beneath your "Live on blog" screenshot.

Once you've opened up your template, place your cursor over the code and click once. Open a search box by pressing ctrl-f if you're on a PC, or command-f if you're on a Mac. Type </head> in the search box that appears in the upper right corner of your template code, then press enter. Your template will jump to the </head> tag and highlight the tag in yellow.

Enter this markup directly above the </head> tag:

Before you save your template, change YOUR-TWITTER-NAME to your actual Twitter name.

Once you've done that, click the "Save template" button.

Step Four: Test Your Markup

Twitter has a testing tool for checking your Twitter Card markup here.

On the tester page, enter the URL of one of your posts (NOT your home page, Twitter Cards only work on post pages) and click "Preview Card". You'll see a demo Tweet with your card attached.

Step Five: Submit Your Twitter Cards Application

Once you've confirmed that your markup is working, you'll need to submit your blog for approval. To get started, click the "apply to participate" link on this page (3rd paragraph). When Twitter gets your application, they'll check your markup and approve you (provided everything is in the right place). They may contact you to let you know you've been approved, or you may just suddenly see your cards working, like I did. I don't know what happens if you don't get approved — probably nothing.

Twitter Cards Support

You can find out more about how the cards work and the different types of options available in the official documentation for Twitter Cards. If you have questions, you may also be able to get help on Twitter's developer forum, which has an active Twitter Cards board.

All About Blogger Search Features

Earlier this year, Google quietly released some helpful new search features for Blogger. The new options improve your blog's appearance in search results and boost its usability for your readers. They were so quiet about it, though, that many bloggers still have no idea these options are available. It's almost like they're a secret!

You know I can't stand to let you miss out on good Blogger stuff, so let me show you what they can do!

To get started, go to Settings > Search Preferences, and click the "edit" link under Meta Tags: Description. Set the "Enable search description?" radio button to "yes", and press save. You'll go back to set your blog's description in a few steps, but let's get started with the post search description.

Search Description

You can find the search description option in the right column of your post editor. It's under "Post settings".

Your search description is your chance to give readers a little preview of your post before they click on your link from a search engine or social network. Here's an example of a search engine result for my Pinterest gadget for Blogger post:

search engine result for Code it Pretty that reads: A jQuery-based Pinterest widget to show off your latest pins on your Blogspot - Blogger blog.

That summary below the link is the custom search description I wrote for the post. It gives potential visitors a good preview of what they'll read if they click on the link. It's short; I kept it under 160 characters because that's the limit of what Google will show on a search engine result. Other search engines will show slightly more, but I think it's best to stay under the lowest limit.

Notice that I wrote this description as a normal sentence, not a series of keywords. That's because the search description is meant for humans. Write your search descriptions in the same voice you use on your blog. You're talking to people here, not robots!

Search Descriptions Work on Facebook, Too

As if the search engine results weren't cool enough, there's another nice benefit to filling in a search description: it gives you control over how your post is described when it's shared on Facebook. Take a look:

Blogspot blog post with custom search description, as it would appear on Facebook.

Great, right? That definitely beats the random excerpts Facebook used to grab from Blogger posts!

Search Preferences

Now let's move on to the new search preferences, which you can find under Settings > Search Preferences.

Blogger settings, search preferences

These new search preferences give you more control over how your blog shows up in search engine results, and let you control what happens when a vistor follows a dead link to your blog. Here's what they do:

Meta Tags: Description

The Description describes your blog to search engine visitors, in the same way the search descriptions describe your individual blog posts. Here's what my custom description looks like in a Google search:

custom meta tag description for Code it Pretty, as seen in Google search results

Again, keep it brief and human-friendly!

Custom Page Not Found

Once in awhile, your readers will follow a dead link to your site and land on your "page not found" error page (also known as a 404 page). The new, "custom page not found" option allows you to customize what your readers see when they land on this page. Now, instead of a discouraging error message, you can give your readers a useful page that can help them find their way to the right part of your blog.

Code it Pretty's custom 404 page

I've added a set of links to my most popular posts on my "page not found" page. And, since the page accepts HTML, I was able to format my links as a list and style the page with CSS. You can see a live example of my custom "not found" page at: http://www.codeitpretty.com/fourohfour.html, or read about how I made it in this post.

Custom Redirects

Not everyone is going to need custom redirects for their blog, but they're incredibly useful in some situations. Here are a couple of good reasons to use custom redirects on your blog:

Correcting misspelled inbound links

Raise your hand if this has happened to you: you tweet a link to your blog, the tweet gets retweeted by your wonderful followers — and then you realize you left off the .html at the end of the URL. In the past, that meant anyone clicking that link would go to your "page not found" page. But, now you can take your misspelled link into your custom redirect editor and point them to the correct page in your blog. Select the "permanent" checkbox to lock the change in.

Redirecting traffic from obsolete pages and posts

If you've removed a popular post or page from your blog, you should redirect traffic from that old page or post to another part of your blog. That way, visitors following older links to the removed parts of your site will get content, not an error page. To keep your readers happy, try to make sure you're redirecting them to the most relevant existing page.

For example, if you remove a cupcake recipe that calls for an ingredient that's no longer available, you should redirect the link to a revised version of the cupcake recipe or a general cupcake recipe section; the more similar the content at the new link is to the content at the old link, the better. That way your visitors are less likely to be confused or annoyed by what they find at the redirected link. Again, select the "permanent" checkbox to lock the change in.

This also works if you've moved to Blogger from a different platform, but kept the same domain name. You may have old links out there to static pages on your old site that don't coorespond to the URL structure of your new Blogger static pages. You can redirect traffic from those old links to your new Blogger pages using the custom redirects.

Temporarily redirecting visitors to a more timely post

Here's another example: let's say you host an annual giveaway for one of your sponsors, and you've been doing it for three years. You still get visits to the old giveaway posts, and many other bloggers have linked to your older giveaways. You can temporarily redirect all of the traffic coming to those older links to your current giveaway, so that your new visitors have a chance to enter the giveaway that's actually taking place. All you have to do to set up a temporary redirect is leave the "permanent" checkbox unchecked, then save the redirect. Once the giveaway is over, you can delete the redirect and traffic will flow to the old pages like it used to.

Crawlers and Indexing

Did you notice the "Crawlers and Indexing" section of the Search Preferences area? Then I'm sure you also noticed the big "Warning!" banner above it. I'll keep this part super-brief: just leave that alone. I know, I know, I'm being vague. But, if you need to use one of those features, you probably don't need me to tell you how to use it. If you're curious, you can check out http://www.robotstxt.org/robotstxt.html for everything there is know about robots.txt.