Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you notify Google through code that there is a updated sitemap?

On this page of Google help:

https://www.google.com/webmasters/tools/docs/en/sitemap-generator.html#submitting

Google mentions that there is a way to notify them of an updated sitemap using an HTTP request.

When you click the link, it takes you to this page:

http://www.google.com/support/webmasters/bin/answer.py?answer=34592&topic=8482&hl=en#ping

But there is no information on where to ping with what request.

Does anyone know what this address is and what parameters are required?

like image 493
Darryl Hein Avatar asked Feb 11 '09 21:02

Darryl Hein


People also ask

How do I know if a sitemap is submitted to Google?

To this use this method of inspection, simply type /sitemap. xml at the end of the domain's URL. For example, if your domain is google.com, you'd navigate to google.com/sitemap.xml to view the sitemap for that domain and see which pages have been indexed.

How do I automatically update sitemap?

How to (automatically) update sitemaps. If you have a small website where content changes happen either on a weekly- or monthly-basis, you can simply create an XML- and HTML-sitemap by hand, any time new content is available and upload it to your webspace.


2 Answers

http://www.google.com/webmasters/sitemaps/ping?sitemap=URL-encoded URL to your sitemap

like image 179
chaos Avatar answered Oct 13 '22 01:10

chaos


Simplest solution: file_get_contents("https://www.google.com/webmasters/tools/ping?sitemap={$sitemap}");

That will work on every major hosting provider. If you want optional error reporting, here's a start:

$data = file_get_contents("https://www.google.com/webmasters/tools/ping?sitemap={$sitemap}");
$status = ( strpos($data,"Sitemap Notification Received") !== false ) ? "OK" : "ERROR";
echo "Submitting Google Sitemap: {$status}\n";

As for how often you should do it, as long as your site can handle the extra traffic from Google's bots without slowing down, you should do this every time a change has been made.

like image 30
jaggedsoft Avatar answered Oct 13 '22 00:10

jaggedsoft