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

Comment Form Message RULES:
Just CLICK on "FACEBOOK" to use it as alternative.
1. Caps allowed in moderation;
3. No Bullying,
4. No Swearing;
5. No Spoiling;
6. No harassing other users;
7. No flooding or spamming;
8. No posting of private contact information;
9. No impersonating other members;
10. Racism of any type NOT allowed.
Use "Contact Form" to send your Article or News.

Note: only a member of this blog may post a comment.