Sitemaps are useful to tell search engines about different pages of your website. Once you submit a sitemap to a search engine, they can crawl all the links which you provided in your sitemap. So generating a sitemap for your website is very important. If you don’t have a sitemap for your site, create one by Google Codes or manually create one by Learning how to create a sitemap (it’s nothing but a simple XML file!)
Now, there are two ways for making a scheduled update for your sitemap:
Automatic: By PHP & Cron Job
Download this PHP file. Give it a name, like “sitemap_updater.php”. Edit it to type in it the correct location of your sitemap. Now upload it to your server, suppose in /public_html/cron_jobs/ directory. Give the file a name, for example, sitemap_updater.php
Now, go to Cron job section of your server from the Control Panel/Admin account of your hosting. If you’ve acces to Cpanel, you may click cron jobs like following:
Next, click a option that suits you most. If you’re new, click standard
Next we’re on the main panel. Select your schedule – how often you want to run the code. Then in the command to run box, type the following command:
php -f /home/your-username/public_html/cron_jobs/sitemap_updater.php
Look at the URL: /home/your-username/public_html/ replace it with appropritae location of your root directory.
If you have a different location for the sitemap_updater.php file, type it accordingly. The following screen-shot might be helpful (ignore the command given in the image)!
More details on Cron jobs here
Download the Sitemap_Updater.php file
Manually Updating Site-maps
Well, if you don’t have access to PHP/Cron jobs, you can manually update sitemaps. The trick is, we will create a HTML file, save it in our local disk, and run the file manually whenever we need to update the sitemap!
- Download this HTML file
- Rename it like something.html
- Open the file for editing, edit line # 5, give here your sitemap address. Save it
- Now whenever you need to update your sitemap, just open the HTML file in your brower! š
Well, that’s all. Rock with your sitemaps š
Thanks for smart way from cron i was looking for it.
The cron job is every 5 min?
The image shown here gives instruction on how to run cron every 5 minutes. You can set an interval that suits your site best š
This is very useful!
Hi, Nice post.
I want to make news site like http://101blogs.com and want that it should be update automatically.
Is there any way?
I need a dynamic sitemap code for php. Can give me any reference ?
Thanks for the script, just testet it, and it works great!
How do i know if its executed successfully? Do i have to submit my website to google webmaster in order to do this?
In the php script you may send a mail to yourself, including the time the script ran. You may submit to google webmaster (recommended) – it’s extremely helpful.
Oh so can i take it that i have to manually submit once to google webmaster and let this script + cron job auto-submit the sitemap afterwards?
Nice post.!!
Thank’s for the script. š
can any one give me for New source code cron???
there bad link…
Link fixed. Thanks for notifying
Hello, If sitemap is more than 50,000 i mean my sitemap is multiple, Automatic Sitemap Updater is compatible ?
This script can only submit one sitemap.xml file at a time!
i want my site to update the xml feed, this script i believe is just for ping the xml feed what is the point if the xml feed sitemap hasn’t been updates. do you have a script and cron for updating the sitemap?