Monthly Archives: April 2012

Fix broken Facebook sharing – Jetpack only shows the post title in og:description

It’s beautiful and sunny outside. The temperature is a refreshing 60 degrees, and I’m eager to get outside and enjoy the day. Before venturing out I say to myself, “Vanessa, there was a great article you wrote a while back, why not share it on Facebook so others can enjoy it?”. With the certainty that it will be quick I hit the share button, craft some stunning literature about why this article is relevant today and spend the next three hours fixing Jetpack’s broken treatment of og:description.

If you’ve found this page, you’re probably struggling with that same thing – when sharing on Facebook, instead of inserting your expertly crafted post description you just see the title repeated again. As great as your site may be, this is not a welcome invitation to sharing. After three hours of investigation, taking my entire network of sites down twice and much help from this Reddit Article, this WordPress forum post and my own limited PHP skills I have a solution to share.

If you’re using Jetpack, there are three things you need to do to get your blog posts to show up with the correct description when shared on Facebook:

  1. Add code to your theme to correctly set the og:description property
  2. Comment out the code in the Jetpack plugin that incorrectly sets this
  3. Make sure your Excerpts are set

 

Add code to your theme to set the og:description property

Add the code below to the header.php file in your theme. You can find this going to your WordPress dashboard, clicking on Appearance, then Editor.  It’s useful to make a careful note of what you’re changing so you can undo it later, or better yet – backup your files before changing. In general changing your theme files won’t cause too many bad things to happen if you get it wrong.

<?php
if (is_home()) {
echo ‘<meta property=”og:title” content=”Your site name”/>’;
echo ‘<meta property=”og:description” content=”Your site image”/>’;
echo ‘<meta property=”og:image” content=”http://images.yoursite.com/image.png”/>’;

}

else {
echo ‘<meta property=”og:title” content=”‘;
echo single_post_title();
echo ‘” />’;
echo ‘<meta property=”og:description” content=”‘;
echo strip_tags(get_the_excerpt());
echo ‘” />’;
}
?>

Comment out the incorrect og:description code in Jetpack

This one is a bit trickier – so be careful! I brought down my entire network of sites twice because I was trying to get too fancy. Yes, it’s possible to edit Jetpack and put all the code there instead of in your theme, but it’s safer to make as few changes to plugins as possible.

First, edit the Jetpack plugin by going to your WordPress dashboard, select Plugins, then Editor. In the top right select ‘Jetpack’ as the plugin to edit. Now choose the ‘sharedaddy.php’ module on the right by clicking it.  Then click on jetpack/modules/sharedaddy/sharing-sources.php, also on the right. Do a search on the page for og:description and you’ll be taken to code that looks something like the below. Comment out the two lines with if ($post… and echo ‘<…

Hopefully Jetpack fixes this in the near future, but until then you’ll need to add the comments back whenever you upgrade your Jetpack plugin.

public function display_header() {
if ( $this->share_type == ‘share’ ) {
// Set the open graph description, otherwise Facebook may pick up some random text from the page
global $post;

//Comment out because Jetpack is lame with og:descriptions
// if ( $post && $post->ID > 0 )
// echo ‘<meta property=”og:description” content=”‘.esc_attr( apply_filters( ‘sharing_post_title’, $post->post_title, $post->ID, $this->id ) ).’” />’;
}
}

Set your excerpts to get the correct og:description

Lastly, you need to set your the excerpt on your post to get the correct description. It’s not enough to have a description set in an SEO plugin like All in One SEO Pack, because the get_the_excerpt() function only looks at the WordPress excerpt. The excerpt should be right under your post edit box in WordPress, though it may be hidden in later versions of WordPress. You can bring it back by selecting Screen Options where you’re editing your post.

Phew!

You’re done! Congratulations! Test everything and do a quick share to make sure everything is working.

Windows Glass – Microsoft’s Problem Isn’t Innovation

This last week Google announced a really exciting look into the future called Project Glass. Naturally, Google debuted it with a YouTube video that enticed you with the possibilities, but they did more than that. This wasn’t some futuristic video meant to inspire people to build interesting products, this wasn’t just a prototype one researcher had cobbled together in a lab somewhere – this was an actual alpha product that many Googlers have since been seen sporting around town. I am, unfortunately, not among them.

Microsoft Windows Glass 2012 Service Pack 2 R3

It didn’t take long for the Microsoft parodies to start. Pitting innovative Google against a Microsoft that was still partying like it was 1995. The first video decries Microsoft’s overuse of dialogs, pop-ups and notifications. I would come to Microsoft’s defense on this one, were it not all too true. It seems like I’m constantly interrupted on Windows by crap I don’t care about. I’m looking forward to my upcoming upgrade to a Macbook Air (Hurry up and release the new ones already Apple!)

 

The parody continues with these old style View-master glasses, wittily branded as Windows Glass. Seeming to reinforce a common perception – while the rest of the world has moved on, Microsoft is just sitting around listening to 8-track tapes and raving about color TV. It’s surely a common refrain from many that Microsoft has lost the ability to innovate, that other large tech companies continually run circles around Microsoft. Whether it’s Apple trifecta of iPod, iPhone, iPad, or Amazon’s AWS or pretty much anything Google has done in the last 10 years.

Microsoft doggedly improves Windows and Office. Milking it’s cash cows for all they’re worth. Sometimes they take a step backwards (Vista, and IMO Windows 8), sometimes they have a hit (Windows 7, Office 2010). All the while slowly losing share in servers, databases and anything to do with the web or big data. Every now and then they’ll strike out in desperation and the predictably grim results – Zune, Windows Phone (though I think they still have time to become a 5% market share player here). Occasionally they’ll do a great job copying a competitor (Bing). Even rarer is the breakout hit where they redefine a market (Xbox).

Looking at this track record it’s easy to assume that Microsoft has an innovation problem. I don’t believe that is true.

Microsoft has a Windows and Office Problem

Specifically, things which aren’t good for Windows or Office rarely, if ever, see the light of day. Like a good example in the making for the next in the Innovator’s Dilemma series these projects are killed. Whether it’s an irony laden turn by Windows/Office senior management to ‘cut off their air supply’, or a slow leaking of resources so the project has no choice but to rot – the end result is the same.

You might think that I’m awfully down on Microsoft, I’m not. The truth is Microsoft is GREAT at innovation. You only need to take a quick gander through some of the great ideas and prototypes that come from Microsoft Research. Everything from the pinch-and-zoom mobile browsing we take for granted on the iPhone (Microsoft and Apple have patent cross licensing deals), or Cleartype text that makes innovative use of LCD characteristics to improve text quality, or XML HTTP Request which birthed web apps.

When I worked at Microsoft I would browse the annual Techfest like a kid in a candy store. The scope of innovation was broad and deep, with some of the best ideas at least on par with Google’s Project Glass. It was a phenomenal demonstration of visionary and innovative thinking.

But it stopped there. It stayed as visionary and innovative thinking. It stayed with the handful of researchers who broke the ground. It rarely made it into a product or shipped alone to users to refine and get feedback. Most of the great ideas died on the floor of Techfest, or came back year after year until it was nothing more than the decaying zombie ravaged by the progress of time and technology.

I Want Microsoft to Deliver Innovative Products

It might sound odd for someone from Google to passionately want Microsoft to deliver innovative products. If you step back for a moment you’ll see that no single company can ever have all the great ideas or push the industry forward. It takes many companies working with slightly different goals and biases to fully explore a space and push technology forward. In fact, it takes more than just companies – universities and government are important partners. If you doubt government’s inclusion you may go ahead and shut off your Internet and stop using GPS now.

Microsoft’s window of opportunity to impact the evolution of technology is closing. Please, don’t kill your innovation before it can grow up.