templates cleaner and generation for all pages
diff --git a/erpnext/patches/may_2012/cms.py b/erpnext/patches/may_2012/cms.py
new file mode 100644
index 0000000..d486fa7
--- /dev/null
+++ b/erpnext/patches/may_2012/cms.py
@@ -0,0 +1,9 @@
+import webnotes
+
+def execute():
+	from webnotes.model.doclist import DocList
+	import os
+		
+	for name in webnotes.conn.sql("""select name from `tabWeb Page` where docstatus=0"""):
+		print name
+		DocList('Web Page', name[0]).save()
\ No newline at end of file
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index 01f4a0e..b4d882b 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -332,5 +332,10 @@
 		'patch_file': 'renamedt_in_custom_search_criteria',
 		'description': 'raname dt in custom search criteria'
 	},
+	{
+		'patch_module': 'patches.may_2012',
+		'patch_file': 'cms',
+		'description': 'generate html pages'
+	},
 
 ]
diff --git a/erpnext/website/doctype/web_page/template.html b/erpnext/website/doctype/web_page/template.html
index b66aded..c6d4b40 100644
--- a/erpnext/website/doctype/web_page/template.html
+++ b/erpnext/website/doctype/web_page/template.html
@@ -2,7 +2,7 @@
 	<div class="web-content" 
 		style="text-align: {{ doc.text_align }};">
 		
-		{% if doc.layout.startswith('Two column') %}
+		{% if doc.layout and doc.layout.startswith('Two column') %}
 		<div class="layout-main-section">
 		{% else %}
 		<div class="layout-main">
@@ -14,7 +14,7 @@
 
 		</div>
 		
-		{% if doc.layout.startswith('Two column') %}
+		{% if doc.layout and doc.layout.startswith('Two column') %}
 		<div class="layout-side-section">
 			{{ doc.side_section_html }}
 			{% if doc.see_also %}
diff --git a/erpnext/website/doctype/web_page/web_page.py b/erpnext/website/doctype/web_page/web_page.py
index 66941e4..a56f7e4 100644
--- a/erpnext/website/doctype/web_page/web_page.py
+++ b/erpnext/website/doctype/web_page/web_page.py
@@ -40,7 +40,8 @@
 			webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
 
 		p = website.utils.add_page(self.doc.name)
-			
+		self.doc.page_name = p.name
+		
 		self.doc.updated = global_date_format(self.doc.modified)
 		website.utils.markdown(self.doc, ['head_section','main_section', 'side_section'])
 				
diff --git a/erpnext/website/doctype/website_settings/website_settings.py b/erpnext/website/doctype/website_settings/website_settings.py
index 8bc7b29..5250213 100644
--- a/erpnext/website/doctype/website_settings/website_settings.py
+++ b/erpnext/website/doctype/website_settings/website_settings.py
@@ -35,7 +35,7 @@
 		"""rewrite all web pages"""
 		import webnotes
 		from webnotes.model.code import get_obj
-		
+			
 		for p in webnotes.conn.sql("""select name from tabPage where docstatus=0
 			and web_page = 'Yes'"""):
 			get_obj('Page', p[0]).write_cms_page()
diff --git a/erpnext/website/utils.py b/erpnext/website/utils.py
index 7ec1b4f..1adc824 100644
--- a/erpnext/website/utils.py
+++ b/erpnext/website/utils.py
@@ -95,7 +95,7 @@
 	return Template("""<div class="navbar navbar-fixed-top">
 		<div class="navbar-inner">
 		<div class="container">
-			<a class="brand">{{ brand }}</a>
+			<a class="brand" href="index.html">{{ brand }}</a>
 			<ul class="nav">
 				{% for page in top_bar_items %}
 					{% if not page.parent_label %}
diff --git a/public/js/wn-web.js b/public/js/wn-web.js
index 5269563..929e539 100644
--- a/public/js/wn-web.js
+++ b/public/js/wn-web.js
@@ -1,4 +1,4 @@
-window._version_number = "c1dee2b8be9abfbe2a74619482b586b538f7253911fcb06c4c950b10";
+window._version_number = "2a070dfb16a80c744b13c7609859086ef91dfd755d70032ee00ee4f6";
 window.home_page = "index";
 // footer signup widget
 // automatically adds it to the .layout-main div of the page
diff --git a/public/login-page.html b/public/login-page.html
index 5b70f86..2f942fc 100644
--- a/public/login-page.html
+++ b/public/login-page.html
@@ -136,7 +136,7 @@
 	<header><div class="navbar navbar-fixed-top">
 		<div class="navbar-inner">
 		<div class="container">
-			<a class="brand">erpnext</a>
+			<a class="brand" href="index.html">erpnext</a>
 			<ul class="nav">