Ping Production Sitemap to Search Engine once Deployment finishes!

TLDR: When the deployment is triggered by static HTML output plugin, ping URL to search engine

My WordPress exists at my computer http://localhost (uses Rankmath, static html output) for daily updating blog at https://www.example.com

I am aware that when we publish post or update, Rankmath ping to Google.

Is there any function that can help in Pinging production Sitemap URL of https://www.example.com from the localhost server after successful deployment from ‘static HTML output plugin’ plugin.

Originally posted at

Added

1 Like

Guess, we can do with JS as well :thinking: with something like this

If /wp-admin/admin.php?page=statichtmloutput DOM has text,  'Process completed'

make a GET request http://www.google.com/ping?sitemap=' . $deployment_detected_sitemap_url

Haha, bit dodgy how they send user to 5-star filtered page when asking them for reviews!

Thanks for putting on GitHub Issues.

I’ll think on how to address it. We can either try to modify the calls that each SEO plugin makes (more work, less reliable, as they don’t share same concept of “deploy” as our plugins) or provide solutions based on our existing post-deployment hooks (preferred, more likely).

We have already in one of the plugins, an option in UI to set a post-deployment webhook URL and choose the method GET, or POST, for which this direction from Google would work:

  • Use the ping tool. Send a GET request in your browser or the command line to this address, specifying the full URL of the sitemap. Be sure that the sitemap file is accessible:
    http://www.google.com/ping?sitemap=<full_URL_of_sitemap>
    Example:
    http://www.google.com/ping?sitemap=https://example.com/sitemap.xml

For a plugin without that option, we can do a little custom script in functions.php or as an extra plugin, which will call that URL. If using via WP-CLI in a script, that can be a simple curl or wget request.

I’ll link back here from the GH Issue and update when there’s a more concrete solution, but you can try out some of the ideas above for now.

1 Like

Steps

  1. Detect which sitemap exists

  2. Then ping it on successful deployment (excluding zip case)

Common sitemap URLs

Most famous is /sitemap_index.xml used by Rankmath and Yoast

Native and few other uses /sitemap.xml

We do not need to ping interlinked .xml file only main first one.

Cool. We have some nice new Sitemap detection going to be added to WP2Static soon, maybe be able to hook in there…

1 Like

Received a reply