Meta Description Generator

Unique meta descriptions help ensure that the search results contain a relevant hook to encourage the searchers to click through. Search engines may also use the meta descriptions and titles of pages to perform a quick check to see if pages are duplicates of one another. Having lots of pages with duplicate meta descriptions can hurt marketing and may also hurt the indexing and ranking of the pages.

Large sites should usually generate meta descriptions automatically because time to write one for each page would be excessive. When an eCommerce site has hundreds or thousands of dynamically generated pages, it makes sense to dynamically generate meta descriptions.  Sometimes the best way to create a meta description is to create a template and perform substitution, such as:

<meta name="description" 
content="Buy {ProductName} ({PartNumber}) for less at CheapWidgets.com. Free shipping."/>

You would use the appropriate syntax and variables for your CMS to replace {ProductName} and {PartNumber} with dynamic values.

When this simple approach results in unappealing or redundant meta descriptions, or just can’t be implemented easily, a more sophisticated approach is to use the content of the page to create the meta description.

CODE SAMPLE

The following PHP code takes a text field, such as a product description, as input and generates an excerpt that will serve as a good meta description.  Use that excerpt as the ‘content’ attribute value in the meta description tag.

/* This PHP Function generates a meta description string at 
least 80 characters long, ending with a period if possible, and no 
more than 156 characters. The output of this function should probably
be html encoded with a function such as htmlspecialchars() for use
in a web page. */

function make_description($code) 
{
  $pagedesc=strip_tags($code);
  $padding = substr($pagedesc, 80);
  if ($padding === 0)
     return $pagedesc; 
  $length = strpos($padding, ".");
  if ($length === 0) 
      return $pagedesc; 
  return substr($pagedesc, 0, min($length + 81, 156)); 
}

ABOUT THE AUTHOR

After graduating from Yale with two degrees in Computer Science, Jonathan Hochman set up his own consulting company in 1990. He has been an Internet marketer since 1994.

For additional information, please contact Hochman Consultants.