 
 		writeAfter: (opts,next) ->
 			docpad = @docpad
+			defaultConfig = @defaultConfig
 			config = @config
 			sitemap = @sitemap
 			templateData = docpad.getTemplateData()
 
+			# create sitemap data object
+			sitemapData = balUtil.extend sitemap, defaultConfig
+			sitemapData = balUtil.extend sitemapData, config
+			docpad.log "debug", sitemapData
+			# set hostename from site url in document
 			siteUrl = templateData.site.url
-
-			# create sitemap data object
-			sitemapData = balUtil.extend sitemap, config.defaults
-			# set hostename from site url in global config
 			sitemapData.hostname = siteUrl ? sitemapData.hostname
 			# use global outPath for sitemap path
 			sitemapPath = docpad.getConfig().outPath+'/sitemap.xml'


			# loop over just the html files in the resulting collection
			docpad.getCollection('html').sortCollection(date:9).forEach (document) ->
				if document.get('sitemap') isnt false and document.get('write') isnt false and document.get('ignored') isnt true and document.get('body')
					# create document's sitemap data
					data =
						url: document.get('url')
						changefreq: document.get('changefreq') ? config.defaults.changefreq
						priority: document.get('priority') ? config.defaults.priority

					sitemapData.urls.push data

			# setup sitemap with our data

		# Configuration values

		# default values
		defaultConfig:
			cachetime: 10*60*1000 # 10 minute cache period
			changefreq: 'weekly'
			priority: 0.5
			hostname: 'http://www.change-me.com'

		# The sitemap being built, to be passed to sitemap.js
		sitemap:
