Creating a Dynamic Sitemap Using Coldfusion

Author: Steven Neiland

Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

Creating an accurate sitemap is a necessity for seo. In addition it serves as an important usability feature for your website. However building a sitemap manually can be a tedious job, and if you have a dynamic site (such as a blog) it can be even harder to keep your sitemap accurate.

Fortunately by using url rewriting and coldfusion we can create a dynamic site map which is built directly by our database on loading. Further we can apply this technique to styling the sitemap using xsl. Here's how.

Before creating a sitemap dynamically let first create one manually to detail the structure.

Step 1: Understanding the XML Sitemap Structure

A standard xml file consists of the follow components.

  1. XML declaration: This is a standard declaration for a xml file.
  2. URLset: This serves as a wrapper for the url nodes.
  3. URL Nodes: A url node is a declaration for a specific page address on the site and consists of the following 4 child nodes.
    • loc: The actual web address of a particular page
    • lastmod: The data the page was last modified in the format "yyyy-mm-dd"
    • changefreq: (optional) How often the page is updated always(changes each view),hourly,daily,weekly,monthly,yearly or never.
    • priority: (optional) Priority you assign this page relative to the rest of the site. A value in the range 0.0 - 1.1 (default 0.5).
  4. As you can see it really is not that complicated to create a sitemap. Here is a simple sitemap listing the home page and a blog page.

    <?xml version="1.0" encoding="UTF-8"?>

1 2 3 4

Reader Comments

David Tananbaum's Gravatar
David Tananbaum
Friday, December 18, 2015 at 3:37:43 PM Coordinated Universal Time

Are you available for assignment to redefine out sitemap code for the website as listed above?

David Tananbaum, Pesident
AtPrime media Services

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain advertisments or appear to be created for the purpose of link building, will not be published.

Archives Blog Listing