Skip to main content
  • Home
  • Work
  • Photography
  • Contact
  • Client Extranet
New Rivers Digital
Home Blogs Eric Weik's blog

Google Site Verification Meta Tag in Drupal / Zen

In:
  • Drupal 6
  • Drupal Recipes
  • Theming
  • Zen
  • Zen Theming
28Nov2009

When verifying a site for Google Webmaster Tools, one of the options uses meta tags, specifically meta name="google-site-verification".

This meta tag only needs to appear on the front page of the site, so we can easily check for "is_front" in Drupal and add the meta tag using the theme_preprocess_page() function.

In the Zen theme (as well as Genesis and many other Drupal themes), headers can easily be added by manipulating $vars['head'] string in the existing theme_preprocess_page(). So to add the google-site-verification meta tag to most themes or sub-themes, it would look something like this:

<?php
function THEMENAME_preprocess_page(&$vars, $hook) {
 
// Other proprocess code is probably already here...
  // ...
  // Put Google    site verification on the front page only
 
if ($vars['is_front']){
   
$vars['head'] .= '<meta name="google-site-verification" content="GOOGLE_CODE_HERE" />'."\n";
  }
}
?>

If you are using a theme other than Zen or Genesis, this code should still work, but you may need to replace $vars[] with a different variable. Note the name of the first parameter to THEMENAME_preprocess_page(), and use it instead of $vars[] if it is different.

  • Eric Weik's blog

Comments

#1 nodewords.module

Eric Weik's picture

Submitted by Eric Weik on Mon, 12/07/2009 - 16:50.

I should point out that for anything beyond the extremely simple case presented here, it is also worth exploring the most excellent and flexible nodewords module for Drupal. It adds per-node meta descriptions, keywords, etc. as well as verification tags for Google, Yahoo, and Bing.

  • reply

#2 Upgrade

Riftstalker's picture

Submitted by Riftstalker (not verified) on Tue, 02/08/2011 - 05:15.

Is that Drupal 7 only? We have been stuck to Drupal 6 for our online RPG. Our custom theme fails all kinds of checks ... I guess we need to upgrade to 7 and migrate to Zen, right?

  • reply

#3 This is Drupal 6

Eric Weik's picture

Submitted by Eric Weik on Wed, 02/16/2011 - 09:23.

I need to go through and update the taxonomy on the site to make it clear what versions things work on, but in this case, the above article is about Drupal 6.

-Eric

  • reply

Post new comment

Warning
I strongly encourage and welcome links and feedback. However, this site is moderated and comments with inappropriate links are rejected. Please do not post a one-line "Me too" or "Great post!" comment just so you can link to your site. Thank you for your understanding.
The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.
  • Use to create page breaks.

More information about formatting options

Blog Posts (RSS)

About

Hello! My name is Eric Weik. I am a computer scientist, photographer, musician, and occasional blogger. New Rivers Digital is my software consulting business. I am dedicated to using open source software and open data standards for Web development and applications integration. In particular, I am an ardent Drupal fan and specialize in Drupal module development, theming, and data architecture integration.

Contact Details

New Rivers Digital
PO Box 784

Lancaster, VA 22503

Voice+1-804-577-8526
Fax +1-804-462-3229
Contact Form

Content Tags

Abstract B&W Celestial Clouds Drupal 6 Drupal Recipes Drupal Sites Estuary Etsy Government Grasses HDR Long Exposure Macro New Rivers Digital Orton Photoblog Photo Expedition Photoset Renderblog RGB Sketchbook Snow Storm Structure Synth Sunflow Sunset Theming Webform.module Wide Angle Zen Zen Theming
more tags

Recent comments

  • This is stunning
    2 weeks 5 days ago
  • #42 worked well for me
    3 weeks 3 days ago
  • Email by country
    12 weeks 3 days ago
  • hid conversion kit
    13 weeks 3 days ago
  • James
    14 weeks 2 days ago
  • Michelle
    14 weeks 3 days ago

Popular content

Today's:

  • Using Drupal Actions, Triggers, and Tokens to Send Notifications About Comments
  • Implementing Flickr Slideshow Links By Theming Flickr.module
  • Non-Unique Conditional Email Addresses with Webform.Module

All time:

  • Using Drupal Actions, Triggers, and Tokens to Send Notifications About Comments
  • Sending Multiple Customized Confirmation Messages with Webform.Module
  • Non-Unique Conditional Email Addresses with Webform.Module

Activity Stream

  • Sun, 01/29/2012 - 22:31

  • Flickr Eric posted #0228 - Sunset Tree 10:31pm #
  • Flickr Eric posted #0225 - Rappahannock 10:30pm #
  • Flickr Eric posted #5617 - Hobie Sailing 11:56am #
  • Mon, 01/16/2012 - 10:43

  • Flickr Eric posted #5687 - Broken Tree (Digital Sketch) 10:43am #
  • Fri, 01/06/2012 - 07:54

  • Flickr Eric posted #8975 - Greenvale Creek 7:54am #
  • Flickr Eric posted #8824 - Grass (blue ch) 7:46am #
  • Flickr Eric posted #5687 - Broken Tree (IR) 7:35am #
  • Flickr Eric posted #3205 - Toadstool 7:21am #
  • Flickr Eric posted #2318 - Tree and Beach 7:13am #
  • Flickr Eric posted #2251 - Low Tide Arrival 7:04am #
more from my activity-stream


I am a member of the Drupal Association.
Eric At NRD on Drupal.org
Circumjacence (Eric Weik) on Twitter
Circumjacence on Delicious
Eric Weik on Linkedin
Circumjacence (Eric Weik) on Flickr
Circumjacence (Eric Weik) at StumbleUpon

Powered by Drupal & Genesis | Valid XHTML 1.0 Strict | Syndicate content RSS Feed

© 2010 New Rivers Digital | PO Box 784 | Lancaster, Virginia 22503 | +1-804-577-8526 | Contact Form