Sharing on Facebook: How to Improve Your Results by Customizing the Image, Title, and Summary Text

Published on June 2nd, 2011
Holding a red leaf at The Monroe Institute


Are you in a hurry? See the manual and automated solutions.

If you find this helpful, consider voting this up at stackoverflow to let others know!


My Motivation

My wife recently made the best ice cream known to man: bay leaf ice cream. Yes, I originally made that same puzzled face and cringed of the idea of adding herbs to my dessert. Honestly, I was shocked at how good it was, so we clearly had to tell the world of our new found discovery.

My wife took a picture, wrote a post, and then tried to share the link when this happened:

Damn you facebook! The script used to select the information to share was skipping the body text and pulling something unexpected. And since we all judge books by their covers (or social media links by their thumbnails), we needed a way to remedy this.

Why You Should Care

You probably just spent a lot of time and effort creating what you feel is important content to share with the world, therefore you should try to get the most bang for the buck for your efforts. If you rely on facebook's scripting, you might get a result that looks like this:

Of course, sometimes an unitentional mishmash may get a higher click rate because people are intrigued, but most of the time you're simply going to get people to pass you by. Attention spans on the internet are non-existant, and there is a never ending array of other, more enticing links to go check out.

The 2 Solutions

In my investigation, I found 2 methods of fixing this: manual and automated. Manual is by far the easiest and more robust, but you're relying on user intervention (do they have the time, skill, and desire to edit). Automation through a CMS (e.g. wordpress, drupal) is awesome but may require a level of expertise a casual blogger doesn't have. So check out both and see which one you can best leverage.

Manual Adjustments

When you drop a link into the facebook share box, you'll see the (1) image, (2) title, and (3) text summary. What you may not have known is they are all editable.

The images are the most obvious and can be toggled simply by the left and right buttons. The title and text summary must be clicked, and then you can adjust it to whatever you like.

Much Better!

Automated Suggestions

I gave some advice on how to do this in Drupal in a previous post, so I want to be a little more high level in the beginning so it's more applicable to all CMS's.

The goal is to inject 3 pieces of HTML into the <head> region.

  1. Title: <title>INSERT POST TITLE</title>
  2. Image: <meta property=og:image content="" />
  3. Description: <meta name=description content="INSERT YOUR SUMMARY TEXT"/>

Notice: If you do these 3 things, you'll significantly increase the odds your suggestions appearing automatically when another user shares your content. However, there are no guarantees. Facebook's algorithm sometimes rejects your suggestion and picks something else it determines is more appropriate. I've noticed 2 trends: image names with spaces in them seem to get ignored (use dashes or underscores instead), AND ALL CAPS caps and/or ("highly punctuated") text will get ignored. Despite that, the success rate appears pretty high as of this date (June 1st, 2011).

The difficult part is doing this programmatically. If you don't know PHP, you're typically out of luck unless there is a contributed module/plugin/theme that can do this for you. The following is such an example.

Automation Example: Drupal's Blueprint Theme

In the Drupal 6 version of the Blueprint Theme, you'll find the following 2 sections of code:

function blueprint_preprocess_page(&$vars) {
  $vars['meta'] = '';
  // SEO optimization, add in the node's teaser, or if on the homepage, the mission statement
  // as a description of the page that appears in search engines
  if ($vars['is_front'] && $vars['mission'] != '') {
    $vars['meta'] .= '<meta name="description" content="'. blueprint_trim_text($vars['mission']) .'" />'."\n";
  elseif (isset($vars['node']->teaser) && $vars['node']->teaser != '') {
    $vars['meta'] .= '<meta name="description" content="'. blueprint_trim_text($vars['node']->teaser) .'" />'."\n";
  elseif (isset($vars['node']->body) && $vars['node']->body != '') {
    $vars['meta'] .= '<meta name="description" content="'. blueprint_trim_text($vars['node']->body) .'" />'."\n";
  // SEO optimization, if the node has tags, use these as keywords for the page
  if (isset($vars['node']->taxonomy)) {
    $keywords = array();
    foreach ($vars['node']->taxonomy as $term) {
      $keywords[] = $term->name;
    $vars['meta'] .= '<meta name="keywords" content="'. implode(',', $keywords) .'" />'."\n";

function blueprint_trim_text($text, $length = 150) {
  // remove any HTML or line breaks so these don't appear in the text
  $text = trim(str_replace(array("\n", "\r", "\r\n"), ' ', strip_tags(html_entity_decode($text, ENT_QUOTES, 'UTF-8'))));
  $text = trim(substr($text, 0, $length));
  $lastchar = substr($text, -1, 1);
  // check to see if the last character in the title is a non-alphanumeric character, except for ? or !
  // if it is strip it off so you don't get strange looking titles
  if (preg_match('/[^0-9A-Za-z\!\?]/', $lastchar)) {
    $text = substr($text, 0, -1);
  // ? and ! are ok to end a title with since they make sense
  if ($lastchar != '!' && $lastchar != '?') {
    $text .= '...';
  return $text;

What this is essentially doing is looking for a node's body text and them slimming it down to 150 characters. This will get us the text summary into the <meta> tag. We'll still have to fix the image issue, which we can do by adding this additional chunk of code.

if($vars['node']->field_image[0]['filepath'] != ""){
  $vars['meta'] .= '<meta property="og:image" content="'.$vars['node']->field_image[0]['filepath'].'" />'."\n";

If you're using wordpress or another CMS, you'll have to do your own due diligence on how to get this working.

Was this helpful?

The APIs are always changing, so this may be irrelevant in 6 months, but the strategy should remain the same. I hope you found this helpful, and feel free to leave feedback if this worked for your or not. Good luck sharing!

Additional Examples


Thanks for reading! If you enjoyed this, can I ask you for a favor?

I would like the opportunity to connect with you on an ongoing basis with the intention that I continue to provide you with valuable information and insights to help transform your life personally and professionally. To that end, it would mean a lot to me if you performed one or more of the following.

  1. Sign up for my newsletter to get new articles sent right to your inbox.
  2. Buy my book, Winning the Lottery Within.
  3. Follow me on Twitter or connect with me on LinkedIn. Don't forget to say hi!
  4. Contact me to setup a free, 15-minute consultation.
  5. Share this article with anyone that might benefit from it.

Thanks again for your time and attention! It means the world to me to know that you gave me this opportunity to connect with you.

About Rick Manelius

Quick Stats: CTO of Contact Mapping. Author of Winning the Lottery Within. Graduated from MIT in '03 (BS) and '09 (PhD). Life hacker and peak performance enthusiast. This blog is my experiment in creative writing, self-expression, and sharing what I've learned along my journey. For more information, read my full bio here or contact me.