A sitemap is a file where you can list the web pages of your site to tell Google and other search engines about the organization of your site content. Search engine web crawlers like Googlebot read this file to more intelligently crawl your site.

Why make an XML Sitemap for Static Files?

Let’s first address the “why” of this script: in lots of cases, you’ll have static files, either they’re PDF’s, or static PHP or HTML files that create a site. I want all of those in an XML sitemap for two reasons:
  • to tell Google that they’re there;
  • to be able to see in Google Webmaster Tools whether they’re all indexed.
This script assumes that all those files are in one directory. I know that’s a bit “lazy”, but if your site spans a lot of directories you probably should be using a CMS.

Configuring the XML Sitemap PHP script

Of course this script needs a bit of configuration before it’ll work well. It has the following constant & variables:
    The directory to search for files in.
    The URL to the Sitemaps directory
    Whether or not the script should parse recursively.
  • $filetypes
    An array of all the file types that you wish to include in your XML sitemap.
  • $replace
    An array of all the files that should be replace with other URL’s, useful to, for instance, replace ‘index.php’ with an empty string, so it’ll look like just example.com/
  • $ignore
    An array of all the files to ignore in the XML sitemap, useful for your config.php, for instance
  • $xsl
    A relative path to the XSL file included in the script from the SITEMAP_DIR_URL location.
  • $chfreq
    The change frequency for files, can be ‘hourly’, ‘daily’, ‘monthly’ or ‘never’.
  • $prio
    The priority, a value between 0 and 1, since you can’t differentiate between files, there’s no big harm in setting them all to 1.

Styling the output of our XML Sitemap PHP Script

Of course, we’ll want our XML Sitemap to look good, as well as work well. For that we use an XSL stylesheet which is included in the download. It makes the XML sitemap look like this:
XML Sitemap PHP Script output, styled with XSL
XML Sitemap PHP Script output, styled with XSL

Download XML Sitemap PHP Script

I’ve added the whole script on Github, so you can play, fork, etc.
Or you could just download the zip.

CLICK HERE To Get it done in 4 Simple Steps Online FREE

Source: www.yoast.com

Post a Comment Blogger