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

Google Site Verification Meta Tag in Drupal / Zen

In:
  • Drupal
  • 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

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, 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 Bookmarklet Celestial Clouds CSA Date Drupal Drupal Recipes Drupal Sites Dynamic Range Estuary Government Grasses Long Exposure Macro New Rivers Digital Photoblog Photoset RGB Sketchbook Snow Storm Sumi-e Sunset Surf Theming Trigger.module Views.module Webform.module Zen Zen Theming
more tags

Recent comments

  • 3.x Beta
    8 weeks 2 days ago
  • Some feedback from Webform 3.x
    8 weeks 3 days ago
  • rainbow art
    8 weeks 3 days ago
  • Sumi
    10 weeks 5 days ago
  • Thanks for this info! I lost
    11 weeks 4 days ago
  • Look into "Comment Notify"
    18 weeks 4 days ago

Popular content

Today's:

  • The Meggy Jr. RGB
  • Implementing Flickr Slideshow Links By Theming Flickr.module
  • Weekly Photoblog 2010 - Week 27

All time:

  • Using Drupal Actions, Triggers, and Tokens to Send Notifications About Comments
  • Implementing Flickr Slideshow Links By Theming Flickr.module
  • Sending Multiple Customized Confirmation Messages with Webform.Module

Activity Stream

  • Thu, 09/09/2010 - 16:24

  • Flickr Eric posted Microcity v2.04.2 (IR sim) 4:24pm #
  • Wed, 09/08/2010 - 13:32

  • Twitter Eric tweeted "@troysomers Mid-September to mid-November is the pinnacle of the year IMHO -- I'm ready!" 1:32pm#
  • Tue, 09/07/2010 - 15:54

  • Twitter Eric tweeted "@troysomers I applaud this idea, even if I won't be able to follow it. Write about what you know and love!" 3:54pm#
  • Twitter Eric tweeted "Well hello again twitter. Long time no see. How about some #photography for the day? http://bit.ly/c6p0XZ" 8:07am#
  • Mon, 09/06/2010 - 21:55

  • Flickr Eric posted DSC04355-foxtails 9:55pm #
  • Flickr Eric posted #04361 - Foxtails 9:54pm #
  • Flickr Eric posted DSC04359-foxtails 9:54pm #
  • Thu, 09/02/2010 - 21:05

  • Del.icio.us Eric linked to The Magic Onions 9:05pm#
  • Sat, 08/28/2010 - 23:00

  • Del.icio.us Eric linked to Fanboy.com 11:00pm#
  • Sat, 08/28/2010 - 22:58

  • Del.icio.us Eric linked to Japanese Emoticons: A Stamp of Success ยป Fanboy.com 10:58pm#
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