place website files in root during production build, and fix ruby errors
diff --git a/_build/production-build.sh b/_build/production-build.sh
index b9a5134..6e0fb18 100755
--- a/_build/production-build.sh
+++ b/_build/production-build.sh
@@ -1,9 +1,15 @@
 #!/bin/bash -e
 
-set -x
+function build() {
+  echo JEKYLL running with: jekyll build --config _config.yml,_build/production-config.yml
+  jekyll build --config _config.yml,_build/production-config.yml || return 1
+  echo JEKYLL completed, now promoting _site/website/ to _site/
+  # the generated files are already in _site/ due to url rewrites along the way, but images etc are not
+  cp -r _site/website/* _site/
+  rm -rf _site/website 
+  echo FINISHED: website pages are in `pwd`/_site 
+}
 
 rm -rf _site
-( jekyll build --config _config.yml,_scripts/production-config.yml && 
-    echo site docs are in `pwd`/_site ) ||
-  echo ERROR - could not build docs in `pwd`
+build || echo ERROR: could not build docs in `pwd`
 
diff --git a/_build/production-config.yml b/_build/production-config.yml
index e9a1f08..38ade04 100644
--- a/_build/production-config.yml
+++ b/_build/production-config.yml
@@ -1,6 +1,8 @@
 
 url: https://brooklyn.incubator.apache.org
-baseurl: ""
+
+path:
+  website: ""
 
 dependency_mode: remote
 
diff --git a/_plugins/brooklyn_metadata.rb b/_plugins/brooklyn_metadata.rb
index 32020a1..c0dcc3d 100644
--- a/_plugins/brooklyn_metadata.rb
+++ b/_plugins/brooklyn_metadata.rb
@@ -6,7 +6,7 @@
 #
 module BrooklynMetadata
 
-  BROOKLYN_VERSION = "0.7.0-M1"
+  BROOKLYN_VERSION = "0.7.0-M1" unless defined? BROOKLYN_VERSION
 
   class Generator < Jekyll::Generator
     def generate(site)
@@ -57,4 +57,4 @@
       }
     end
   end
-end
\ No newline at end of file
+end
diff --git a/_plugins/read.rb b/_plugins/read.rb
index 6ad390a..e4058e5 100644
--- a/_plugins/read.rb
+++ b/_plugins/read.rb
@@ -17,7 +17,7 @@
     end
     def render(context)
 	jekyllSite = context.registers[:site]
-	dir = jekyllSite.source+'/'+File.dirname(context['page']['url'])
+	dir = jekyllSite.source+'/'+File.dirname(context['page']['path'])
 	filename = @text.strip
         filename = context[filename] || filename
 	if !filename.match(/^\/.*/) 
@@ -43,7 +43,7 @@
 # support vars (above) and relative paths in filename (below - need the right path if there is a subsequent link)
         dir = filename
 	if !filename.match(/^\/.*/) 
-		dir = File.dirname(context['page']['url']) + '/' + filename
+		dir = File.dirname(context['page']['path']) + '/' + filename
 	end
 	dir = dir.gsub(/\/\/+/,'/')
 	filename = dir.sub(/^.*\//, '')
diff --git a/_plugins/site_structure.rb b/_plugins/site_structure.rb
index 049cc65..6cfe1f9 100644
--- a/_plugins/site_structure.rb
+++ b/_plugins/site_structure.rb
@@ -1,8 +1,8 @@
 # Builds a hierarchical structure for the site, based on the YAML front matter of each page
 # Starts from a page called "index.md", and follows "children" links in the YAML front matter
 module SiteStructure
-  
-  ROOT = "/website/index.md"
+ 
+  BROOKLYN_WEBSITE_ROOT = "/website/index.md" unless defined? BROOKLYN_WEBSITE_ROOT
   
   class Generator < Jekyll::Generator
     def find_page_with_path_absolute_or_relative_to(site, path, referrent)
@@ -16,12 +16,17 @@
       end
 
       throw "Could not find a page called: #{path} (referenced from #{referrent ? referrent.path : "root"})" unless page
-      
+
+      if (page.url.start_with?("/website"))
+        page.url.slice!("/website")
+        page.url.prepend(site.config['path']['website'])
+      end
+ 
       page     
     end
 
     def generate(site)
-      root_page = find_page_with_path_absolute_or_relative_to(site, SiteStructure::ROOT, nil)
+      root_page = find_page_with_path_absolute_or_relative_to(site, SiteStructure::BROOKLYN_WEBSITE_ROOT, nil)
       navgroups = root_page.data['navgroups']
       navgroups.each do |ng|
         ng['page'] = find_page_with_path_absolute_or_relative_to(site, ng['page'], root_page)
@@ -30,7 +35,7 @@
         end
       end
       site.data['navgroups'] = navgroups
-      site.data['structure'] = gen_structure(site, SiteStructure::ROOT, nil, navgroups)
+      site.data['structure'] = gen_structure(site, SiteStructure::BROOKLYN_WEBSITE_ROOT, nil, navgroups)
     end
     
     def gen_structure(site, pagename, parent, navgroups)