Back to top

Using Drupal's Meta tag module for Facebook Open Graph, Google rel=author, and Page titles

Meta tags have gone back and forth in terms of their usefulness for promoting your site. In the late 90s they were a way for nascent search engines to easily categorize sites, then they were abused for keyword stuffing unrelated to page content and their use waned, but they are back again with three major purposes: Facebook Open Graph, Google Authors and Page titles. These are not necessarily "SEO" purposes, but the goal is ultimately the same: making sure that your site puts its best foot forward to gain new visitors.

Metatag module setup

The basic Metatag module setup is pretty straightforward. Download the latest version from the metatag project page. If you don’t have them already you will need the CTools and Token modules.

Setting up Metatag for Facebook Open Graph

There were a few different things I wanted to achieve with the Facebook Open Graph support. Basically, whenever someone includes our page on Facebook I wanted to make sure that the title, description text, and image that Facebook pulled in were the best possible images. I expect that most of the "liking" will occur on our card landing pages. So, I enabled the "Meta tags: Open Graph" sub-module that is included in the main Metatag module. Then I added a meta tag default for the "Campaign" node type by clicking on the bright "Add a meta tag default" at the top of the page on the page at Administration - Configuration - Search and metadata - Meta tags.

I set the "Open Graph Title" to be "[node:title] Prepaid Visa Debit Cards" "Open Graph Description" to be the default "[node:summary]" and for the Open Graph Image I’m using a token that eventually points to the image URL of a field collection: [node:field-campaign-art:0:field_campaign_card_img]. That token is only available if you have Entity tokens module installed from Entity API module. Note that the node:summary token is somewhat broken in core - check out this issue for a patch that at least somewhat fixes it.

The result is wonderful:

Whenever a user includes one of our pages in their post they get a nice title, description and image that are pre-selected into the page. Previously Facebook was pulling copy from the footer and random images from anywhere on the page.

Setting up Google Author support

Google has started including the author’s image and some other metadata in their search results for pages that have a rel=author pointing to a Google+ profile. They’ve also said that they are using author information (and probably social circles) to boost results if that will improve results for the person searching. Regardless of whether this tool helps boost your position in the search engine results page, the extra metadata along side the result does help click through rates. Here’s an example of what this helped us achieve:

I achieved this by creating a profile field on each user account at Administration - Configuration - People - Account settings - Manage fields using the URL field. Then on Blog Nodes I set the "Author URL" field to be the token: [node:author:field_google_plus_profile]. This creates a rel="author" link tag in the head of the html. It was actually hard to find any documentation saying that this style of tag would work, but indeed it does.


There is one more step to fully make it work. Inside of your Google+ profile click to edit the profile and then down at the bottom add the site as somewhere you "Contribute". That is part of a two-way verification so that Google can be sure the author actually wrote the post.

The author tag was something not originally supported by Metatag when I first added it, but luckily it’s very easy to add more tags and I was able to contribute a patch which is now committed.

Page titles

I have long used the Page Title module for Drupal to get custom page titles. It has worked well and I’ve had no reason to stop using it...except when I noticed that I could manage the same title tags using the Metatag module. Whenever I can reduce the number of modules in use on a site I’ll go for it - it means updating one fewer module when new releases come out, learning one fewer code-base if I need to make.

The main things I wanted to achieve with the page titles were to get the keywords we care about at the right points. The default of "node title | sitename" gave us things like "Puerto Rico | CARD.com". Of course I’d much rather have it say Puerto Rico Prepaid Visa Debit Cards | CARD.com so I set the "Page title" to be [node:title] Prepaid Visa Debit Cards | [site:name]

Summary

The Metatag module is a pretty sweet tool for Drupalers. I encourage you to try it out.

People Involved: 

Comments

tokens help

Hi im using tokens as well meta tags modules , but havent been able to track the url for the big image, of the article, how did u got those variables from the token?

I have site in which i have

I have site in which i have used url redirect and pathauto module but when "Generate automatic URL alias " is checked in Url Path setting then title, description and image not displaying in facebook post. Also i have generated pattern for url alias and "Generate automatic URL alias " is checked by default. Can you please explain why its not working.