I am trying to verify my site to google with a meta tag they require:

Copy the meta tag listed below and paste it in your site's homepage in the first <head> section of the page, before the first <body> section

When i add the tag they have given me it changes and i cannot verify. I am adding the line to my homepage using FireBug.

Could someone please help?

Comments

GavinC’s picture

Can anyone help? please

esdaniel’s picture

Just in case anyone else finds this thread and wonders how to hack this....

For v6, edit file /includes/common.inc by adding the meta tag as per below:

/**
 * Retrieve output to be displayed in the head tag of the HTML page.
 */
function drupal_get_html_head() {
  $output = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" .
  '<meta name="google-site-verification" content="<put your goog verify code here>" />\n';
  return $output . drupal_set_html_head();
}
alanaim’s picture

I dropped the code right here at the top of the file right after

<?php
// $Id: common.inc,v 1.756.2.79 2010/03/04 00:15:28 goba Exp $

/**
* Retrieve output to be displayed in the head tag of the HTML page.
*/
function drupal_get_html_head() {
  $output = "\n" .
  '" />\n';
  return $output . drupal_set_html_head();
}

the information in the blue box is there they just won't paste to the post.

...but it still won't verify.

Anybody know what I'm missing?

chrisparsons’s picture

You shouldn't do it that way... you really should never be messing with the includes folder unless you really know what you're doing. Once you edit the core files, upgrading between versions becomes a nightmare.

Not sure if this was around when the original post was made, but there's the Site Verification module - as those below have said, you can just upload the HTML file, but if you want to administer them from within Drupal, this module does work.

GavinC’s picture

Anyone?

1websitedesigner’s picture

If you're trying to set up Google Apps or perhaps Google Adsense, then I find it easier to add a new page, rather than adding the metatag to your website design. Simply do the following:

1. Make sure you have clean urls installed (I'd recommend this anyway) and set it so that you can rename the URLs of pages.
2. Click Create New Content and create a page.
3. In the URL field enter the name to the file that they ask you to upload (e.g. googleasdf1234nsdf.html) - make sure you include the .html in the name.
4. I tend to use the same thing for the title and add it to the text too, but that's just me.
5. Click 'Validate' or whatever in the Google window.

Hope that helps!

Website design, website promotion and SEO

GavinC’s picture

Aminto:

Thank you for your reply. It is for Google Webmaster Tools.

I did as you said, but it has failed to validate :(

I created a new page with title: googled855e1a93d06ae1f.html
Added it in the body: googled855e1a93d06ae1f.html
And renamed the Auto Path to: googled855e1a93d06ae1f.html

And still says it cant find it.

Says Apache is kicking out a 2xx error instead of 4xx, how can i change this?

avpaderno’s picture

The W3C web site reports that

10.2 Successful 2xx
This class of status code indicates that the client's request was successfully received, understood, and accepted.

But then it also reports that

10.2.5 204 No Content

The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant.

If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.

The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.

If you are able to understand which HTTP status code is being returned, that would be helpful. Try checking that page from your web browser, and see if it gives you back an error, or what else it outputs.

GavinC’s picture

Its returning a Successful 2xx, but Google requires a 404 to be returned

avpaderno’s picture

I find strange that Google Webmaster Tools would require a 404 code to be returned. In that case, all the web sites which don't have the required file would be authenticated (because in such case they would return the 404: file not found HTTP code).

I can report that XML Sitemap doesn't return a 404 HTTP code, and it doesn't cause the authentication to fail.
This is the code used from that module to return the authentication content request by various search engine tools:

function xmlsitemap_engines_verify($engine) {
  switch ($engine) {
    case 'google':
      print '<html>'."\n";
      print '  <head>'."\n";
      print '    <title>Hello, Google!</title>'."\n";
      print '  </head>'."\n";
      print '  <body>'."\n";
      print '    <p>Hello, Google!</p>'."\n";
      print '  </body>'."\n";
      print '</html>'."\n";
      break;
    case 'yahoo':
      print variable_get('xmlsitemap_engines_yahoo_verify_string', '');
      break;
    case 'live':
      print '<?xml version="1.0"?'.">\n";
      print "<users>\n";
      print '    <user>'. variable_get('xmlsitemap_engines_live_verify_string', '') ."</user>\n";
      print "</users>\n";
      break;
  }
  drupal_page_footer();
  exit;
}

That is the code for a menu callback, but what is important here is the print() statements.

GavinC’s picture

So would it be worth installing the XML Site map?

This is what is coming back from Google:

Verification status: NOT VERIFIED
Last attempt Jan 21, 2009: We've detected that your 404 (file not found) error page returns a status of 200 (Success) in the header.

avpaderno’s picture

XML Sitemap is a module that has other purposes; as it has the code for the authentication of a web site, that is used when you submitte a XML site map to Google Webmaster Tools, I showed the code used by that module to make you see what it does to authenticate the web site.

In the issue you have, the problem is caused by the fact you gave them a page which returns a 200 HTTP code, while they are expecting a 404 HTTP code. They asked you the page which is returned in the case it's requested content that is not present, and that they expect to set the HTTP code to 404.

I am not 100% sure, but I think that when you try to access a page that doesn't exist, Drupal shows you the error page, but it sets the HTTP code to 200. If is true, even if you would give them a wrong Drupal page URL for the page they are requesting, Drupal would not set the HTTP code to the value they are expecting.

I will investigate on this.

I am sorry if my first answer was not correct, but I misunderstood the question being asked.

avpaderno’s picture

I checked it using curl, and it seems Drupal sets the HTTP code correctly.
This is the output curl returns me if try to access http://avpnet.org/deersf (which is a page that doesn't exist):

> GET /deersf HTTP/1.1
> User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3
> Host: avpnet.org
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Thu, 22 Jan 2009 08:14:05 GMT
< Server: Apache/1.3.41 (Unix) PHP/4.4.6 mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 mod_perl/1.30 FrontPage/5.0.2.2635 mod_ssl/2.8.31 OpenSSL/0.9.7a
< Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0
< Expires: Sun, 19 Nov 1978 05:00:00 GMT
< X-Powered-By: PHP/5.2.6
< Set-Cookie: SESS503f9a4b1130bdd170bd581436c95f9e=b15b7cb8929b7c5051e5927243fe25a5; expires=Sat, 14 Feb 2009 11:47:25 GMT; path=/; domain=.avpnet.org
< Cache-Control: max-age=1209600
< Expires: Thu, 05 Feb 2009 08:14:05 GMT
< Last-Modified: Thu, 22 Jan 2009 08:14:05 GMT
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=utf-8

In your case, I would think that it's enough you give them the URL of a page that doesn't exist in your Drupal-powered web site; in that way, Drupal would return the error page, and it would set the HTTP code to the value they want.

GavinC’s picture

People have mentioned about hardcoding the Google Meta Tag into the page.tpl.php file for my theme.

How can this be done?

http://drupal.org/node/68648 : Comment by: friendster - March 31, 2007 - 22:41

avpaderno’s picture

I guess you need to know something more.
What did you not understand about that? Do you need to know where that file is found?

GavinC’s picture

I need to know what the tags are. As i have tried just putting the meta tag in:

meta name="verify-v1" content="2X0ZWubP07CWjIOpUNuq885eD3l1NHJkC5k1v/pPbyI=" /

But it fails. Is there some sort of PHP coding that needs to rap round it?

avpaderno’s picture

It just needs to be put in the <head> tag.
I cannot tell you which is the right value for the name, and content attributes for the <meta name=".." content=".." /> tag. I checked on Google Webmaster Tools, but it doesn't let me see; I used the other method to authenticate, and it doesn't show me the meta tag I should use for the meta tag authentication.

GavinC’s picture

I have added the Mate Tag google gavin me into the Page.tpl.php for the theme i am using. And still cannot get verified

avpaderno’s picture

I am not sure a browser tools is able to permanently change the content of a meta tag present in a Drupal page.
I think FireBug can temporary change the content of an HTML page for debug purposes, but it cannot change the content of a file served from a server.
That is the reason the meta tag content keeps to change.

The suggestion made from Aminto is the solution to your problem.