How to submit a sitemap in Google webmaster tools programmatically with PHP?

721 views Asked by At

I have a Drupal site with 25k pages and 3k users. It's content is growing signicantly every month.

I wish to submit a sitemap programmatically to Google Webmaster Tools of every user with it's own content.

I'm able to create a sitemap, with custom code o with a contributed module.

I'm also able to create a sitemap for every user with his content... Not a problem.

The problem is that I don't know if there's a way to submit a sitemap programmatically to Google Webmaster Tools with PHP... so I can do it for every user.

And... what happens when a user cancel his account? Well.. If you tell me also how to remove a sitemap would be great.

I found libraries for many languages, but none for PHP.

Thanks!

1

There are 1 answers

3
mgrueter On BEST ANSWER

I think the best way to achieve this, is submit a single URL to the webmaster tools and generate a sitemapindex with your user accounts, that lead to the sitemap of the specific user site out of Drupal. This way you could check the account status of the user and just omit this sitemap in the sitemapindex.

e. g.

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
      <loc>http://domain.com/user/1/sitemap</loc>
   </sitemap>
   <sitemap>
      <loc>http://domain.com/user/1/sitemap</loc>
   </sitemap>
 </sitemapindex>

I'm not really sure about the removal process. You'll probably have to work with removing the sitemap from your sitemap index, and then either 404 the site of the canceled account, or let them run with the <meta name="googlebot" content="noindex" /> meta tag to get them removed from the index.