Creating Your Own Sitemap

ADVERTISEMENTS

Share
Bookmark and Share

You've already seen the nuts and bolts of the Sitemap protocol language, along with the basic template for a Sitemap XML document. It's time to take the next step and create your very own Sitemap document, or in reality, my very own Sitemap document because you're going to use URLs on my web site as examples. Let's get started!

A Basic Sitemap Document

Listing 20.1 contains the code for a complete Sitemap document for my web site. By complete, I mean that it meets all of the requirements of a Sitemap document, although it doesn't actually include URLs for all of the pages on my site.

Listing 20.1. A Complete Sitemap Document for My Web Site
1:
2: 3: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4: xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
5: http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
6:
7: http://www.xyz.com/
8: 2005-08-23
9: daily
10: 1.0
11:

12:
13: http://www.xyz.com/mambo/index.php?
14: option=com_content&task=category&sectionid=2&id=11&
Itemid=35

15: 2005-08-20
16: weekly
17: 0.8
18:

19:
20: http://www.xyz.com/mambo/index.php?
21: option=com_content&task=blogcategory&id=16&Itemid=37

22: 2005-08-23
23: daily
24: 0.8
25:

26:
27: http://www.xyz.com/mambo/index.php?
28: option=com_simpleboard&Itemid=48&func=showcat&catid=37

29: 2005-08-18
30: daily
31: 0.6
32:

33:
34: http://www.xyz.com/mambo/index.php?
35: option=com_simpleboard&Itemid=48&func=showcat&catid=36

36: 2005-08-21
37: daily
38: 0.6
39:

40:


This code is very similar to the Sitemap code you saw earlier in the chapter, except in this case multiple URLs are specified. Notice that I opted to use all of the optional tags in every URLthere's no good reason not to unless you just don't want to take the time to be so detailed. One thing I did skimp on a little is the tag for each URL, which I specified only as a date. However, because none of these pages are listed as having a change frequency higher than daily, it really isn't necessary to get more exacting with the modification date.

By the Way

Google requires all Sitemap documents to use UTF-8 encoding (see line 1 in the example), as well as escaped entities for the following symbols: &, ', ", >, and <.


One other thing worth pointing out in this sample Sitemap is how I opted to use 0.6, 0.8, and 1.0 as the priority levels of the pages. Presumably, a more complete sample page would continue on down the range, finishing up at 0.0 for the least important pages.

By the Way

A Sitemap document can only reference URLs in the same folder or a child folder of the location of the Sitemap file. In the sample in Listing 20.1, the file would need to be placed at the same level as http://www.xyz.com/ because that URL is hierarchically the highest URL in the Sitemap.

top