A good[ish] website
Web development blog, loads of UI and JavaScript topics
You can tell Google or Bing about the changes that have happened in your site, by pinging them your changed sitemaps.
"Pinging" in this case means sending a GET request to a provided endpoint. So nothing magical there.
Let’s say your site’s domain is the classic example.com, in that case you would send a GET request to a URL looking something like this:
https://www.google.com/webmasters/sitemaps/ping?sitemap=https://example.com/sitemap.xml
https://www.bing.com/ping?sitemap=https://example.com/sitemap.xml
Of course this up to your project, but here’s some ideas.
Here’s an example how to do the GET request using the popular Axios http client. Note that we don’t need to wait for the requests, since we don’t care about the response:
const pingSearchEngines = sitemap => {
const google = `https://www.google.com/webmasters/sitemaps/ping?sitemap=https://example.com/${sitemap}`
const bing = `https://www.bing.com/ping?sitemap=https://example.com/${sitemap}`
axios.get(google).catch(console.log)
axios.get(bing).catch(console.log)
}
Fetch is pretty much the same:
fetch(url).catch(console.log)
You could have something like this:
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
curl -S -s -o /dev/null "https://www.google.com/webmasters/sitemaps/ping?sitemap="$1
curl -S -s -o /dev/null "https://www.bing.com/ping?sitemap="$1
echo "Sitemaps pinged"
This -S -s -o /dev/null
makes curl silent, but prints errors.
Usage:
$ ping.sh https://clubmate.fi/sitemap.xml
Just go the URLs 🤷♂️
Or use Google Search Console to submit the sitemaps:
Google doesn’t define a limit. For example on a site I’m working, we have a 30 minute cache for the sitemaps, so we ping every 30 minutes. The request is inside the code that created the sitemaps, so it runs when the cache expires, either on its own or when a deployment happens.
Comments would go here, but the commenting system isn’t ready yet, sorry.