Drupal 7 Blog Google Authorship Image

The following instructions detail how to have Google display your authorship image for blog posts in Drupal 7. This is the image that shows up next to a search result such as this:

Drupal 7 Authorship Step 1

Google has created a method to do this by using your Google+ profile and a couple of links. Google uses your Google+ profile image to display, you link your Google profile to a central author page on your website and you link your blog posts to your author page. This allows Google to verify that it is you writing the posts.

Warning: There is a high probability this content is outdated or incomplete and is left here purely for archival purposes
Drupal 7 Authorship Step 2

Google+ allows you to define links to websites you contribute to, from that page you link back to your Google+ profile with a link with the attribute rel=”me”. This creates a link that verifies that the author page belongs to you. From each blog post you link to your author page, the link needs to have the attribute rel=’author’ this tells Google that the author page at the other end of the link is the person who wrote the article.

The following steps detail to how to achieve this using Drupal 7, this is by far the easiest method (it does involve editing one line of code) however once this is done you don’t have to worry about anything but posting new blog entries.

I am going to assume you have already installed the blog module and started posting.

If you notice on your blog you probably have a link that looks like the image below. It links to a list of all your other blog posts. We are going to use this link to link to an author page. Unfortunately this link is missing the rel=”author” attribute so we need to edit the blog modules source code to add it

Drupal 7 Authorship Step 3

From inside your sites root directory go to modules/blog/ Make a backup copy of blog.module them open it in a text editor. Find the function blog_node_view it should be on about line 80 and looks like the following

function blog_node_view($node, $view_mode) {
   if ($view_mode != 'rss') {
     if ($node->type == 'blog' && (arg(0) != 'blog' || arg(1) != $node->uid)) {
       $links['blog_usernames_blog'] = array(
         'title' => t("!username's blog", array('!username' => format_username($node))),
         'href' => "blog/$node->uid",
         'attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($node)))),
       $node->content['links']['blog'] = array(
         '#theme' => 'links__node__blog',
         '#links' => $links,
         '#attributes' => array('class' => array('links', 'inline')),

Notice the line

'attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($node)))),

This needs to be changed to

'attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($node))), 'rel' => 'author'),

Save blog.module and the hard part is done.

At this point you need to get a Google+ account if you don’t already have one. Set your profile picture to the one you want to show up in the search results.

Now we need to setup an Author page for each blogger. This process isn’t very scalable but I assume you are using Drupal as a CMS with a small Blog as opposed to a full blog. Log into your Drupal website and in the top admin menu select structure, then blocks. In the top left select add block.

Enter a unique block description then enter a bio for the author. The only requirement is that you have to link to your Google+ profile and the link must have the attribute rel=”me” for example mine is:

<a href="https://plus.google.com/u/0/106731320068120193359" rel="me">Peter Blackford</a>
Drupal 7 Authorship Step 4

Once you have completed the bio and the Block Description scroll down to the “Show block on specific pages” section. Select the radio button to Only the listed pages. You now need to determine the the link to the authors blog. In a new Tab/Window go to a post by the user and hit that link shown early E.g “Peter Blackford’s blog” You will be taken to a new webpage with a list of all the authors posts. Look at the URL and grab everything after the domain name and first slash. For instance mine takes me to:


Enter in the value into the textbox below the radio button you just selected. I enter

Drupal 7 Authorship Step 5

Click the save block button at the bottom when you are done. This creates a new block of text that will only be shown on the users blog summary page creating an author page. When you click save you are taken back to the Blocks administration page. The block you just created will be shown under the Disabled heading, change the region drop down to Content. The block will now move to under the Content heading, use drag and reorder icon at the start of the row to ensure the block is at the top directly under the Content heading, then click Save Blocks at the bottom.

Drupal 7 Authorship Step 6

Almost done.

If you now click the “Usernames blog” link under a blog post you should see the block you created for that author. The only thing left to do now is create a link from the authors Google+ profile to the author page. Log into your Google+ account, on the left hand side click the profile icon.

Drupal 7 Authorship Step 6

At the top click the edit profile button

Drupal 7 Authorship Step 7

Scroll down to the Contributor to section and click it. A new section will open, click the “Add custom link” link. The label can pretty much be anything you want however the link must point to the author page

Drupal 7 Authorship Step 8

Once done click the save button. You will then have a blue bar with a Finished Editing button, click the button when you are done.

Configuration is done now you can use Googles Rich Snippets Tool to check what you have done is working. Enter the URL of one of your blog posts in the field and click preview. You should see something similar to the following:

Drupal 7 Authorship Step 9

If it has any issues it will tell you so you can start tracking down what the issue is.

Your image should start showing up in Googles results however this process may take weeks.