How to Create an XML Sitemap
XML sitemaps are files written in a special version of XML that interacts with the Google search engine. Sitemaps tell the search engine specific information about each page of a website. This helps the search engine know more about your site and in return makes it easier to find. Specifically, sitemaps provide Google with each URL of the site, the last date it was modified, the frequency with which it is modified and the priority of importance for each page. This article demonstrates how to construct a basic sitemap for a site with two hypothetical Web pages. It also shows how to publish the sitemap to Google.
Things You'll Need
- Text editor, e.g. Notepad, ConText, Emacs
- Server space to host Web pages
- Active Google account
- HTML server
Instructions
-
-
1
Create the page headers. To create the page headers, all XML sitemaps require the same code. Copy the following to the top of a text document:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">The "<urlset>" tag serves as the root node.
-
2
Create the <url> tag. The url tag serves as the mother tag to each individual URL address provided. Simply type "<url>" under the "<urlset>" tag. The sample document in this article will only have two <url> tags.
-
-
3
Create the "<loc>" tag. Type "<loc></loc>" under the "<url>" tag. Write the address of the Web page between the <loc> tags, for example:
<loc>http://www.your_domain.com/page_1.html</loc>
So far, your document should be as follows:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
<url>
<loc>http://www.your_domain.com/page_1.html</loc> -
4
Create the "<lastmod>," "<changefrec>" and "<priority>" tags. To add these tags, type the following:
<lastmod>2009-07-20</lastmod>
<changefrec>daily</changefrec>
<priority>1.0</priority>The "<changefrec>" tag can include "hourly," "daily," "weekly," "monthly" or "yearly." The "<priority>" tag information can be a value from 0.1 to 1. Close the input for page_1 with a "</url>" tag.
-
5
Add more URLs. You must open the next entry with a "<url>" tag and include the same information as for page_1. You can add up to 50,000 different URLs. Close the sitemap with a </urlset> tag. The entire sample sitemap should look as follows:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
<url>
<loc>http://www.your_domain.com/page_1.html</loc>
<lastmod>2009-07-20</lastmod>
<changefrec>daily</changefrec>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.your_domain.com/page_2.html</loc>
<lastmod>2009-07-20</lastmod>
<changefrec>weekly</changefrec>
<priority>.7</priority>
</url>
</urlset>Note that page_2 has been assigned less priority and is changed on a weekly basis. Save the document as "sitemap.xml" and upload to a directory of choice on your HTML server. Make sure to add your own information.
-
6
Submit the sitemap to Google. Log into Google Webmaster Tools (see Resources below) and enter your website's address in the "Add a Site" option. When the address has been verified, select the "Sitemaps" option under "Site Configuration." You will then be given a text box where you must fill in the path to the sitemap on your server. Finally, press "Submit Sitemap."
-
1
Tips & Warnings
Yahoo! also offers sitemaps but may require a different format. XML sitemaps are most commonly used with Google.
XML sitemaps must contain at least the header, the <urlset>, <url> and <loc> tag information. The rest is optional. However, the more information you add, the better your site will be indexed.
Google might not be able to verify your Web page and may require you to add meta tags to your page and then resubmit.
Your pages will not automatically be indexed by Google. It could take a while before you see any results.
References
- Sams Teach Yourself XML in 24 Hours, Third Edition; M. Morrison; 2005
Resources
- Photo Credit http://www.acasillas.com/Images/sitemap.jpg