PHP Google Search Sitemap Generator Script

You can use this script to create the google sitemap XML for your site automatically. The script will recursively visit all files on your site and create a sitemap XML file in the format needed by Google. This site is targeted at sites with static content.

You can customize the result by changing the starting priorities.

Sitemap Generator Code

Download this file and rename it as 'create_sitemap.php'

Download Google Search Sitemap Generator Script - 8.2 KB

Working of Google Sitemap Generator

First, you have to edit the first few lines of the script to match the setting of your site. The comments explains what needs to be entered. Please note that you have to have a basic understanding of PHP to do this.

After configuring, just run the file every time you make a change to your site. The script will automatically recreate the sitemap - with the new content included.

Configuration

These are the lines that must be edited...


<?php
$url 
"http://www.bin-co.com/"//The Url of the site - the last '/' is needed

$root_dir '../..'//Where the root of the site is with relation to this file.

$file_mask '*.php'//Or *.html or whatever - Any pattern that can be used in the glob() php function can be used here.

//The file to which the result is written to - must be writable. The file name is relative from root.
$sitemap_file 'sitemap.xml'

// Stuff to be ignored...
//Ignore the file/folder if these words appear in the name
$always_ignore = array(
    
'local_common.php','images'
);

//These files will not be linked in the sitemap.
$ignore_files = array(
    
'404.php','error.php','configuration.php','include.inc'
);

//The script will not enter these folders
$ignore_folders = array(
    
'Waste','php_uploads','images','includes','lib','js','css','styles','system','stats','CVS','.svn'
); 

To Do

This is a beta software - a lot of work need to be done before this can be perfect

License

MIT License

Subscribe to Feed