diff --git a/_includes/nav.html b/_includes/nav.html
index e41f79e91ec20941a20f68ec437daf6738690881..8f0b089992109cb902b16b68b2dbaa6845f14a65 100644
--- a/_includes/nav.html
+++ b/_includes/nav.html
@@ -1,51 +1,55 @@
-<nav role="navigation" aria-label="Main navigation">
-  <ul class="navigation-list">
-    {%- assign ordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order != nil" -%}
-    {%- assign unordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order == nil" -%}
-    {%- if site.nav_sort == 'case_insensitive' -%}
-      {%- assign sorted_ordered_pages_list = ordered_pages_list | sort_natural:"nav_order" -%}
-      {%- assign sorted_unordered_pages_list = unordered_pages_list | sort_natural:"title" -%}
-    {%- else -%}
-      {%- assign sorted_ordered_pages_list = ordered_pages_list | sort:"nav_order" -%}
-      {%- assign sorted_unordered_pages_list = unordered_pages_list | sort:"title" -%}
-    {%- endif -%}
-    {%- assign pages_list = sorted_ordered_pages_list | concat: sorted_unordered_pages_list -%}
-    {%- for node in pages_list -%}
-      {%- unless node.nav_exclude -%}
-        {%- if node.parent == nil and node.title -%}
-          <li class="navigation-list-item{% if page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}">
-            {%- if page.parent == node.title or page.grand_parent == node.title -%}
-              {%- assign first_level_url = node.url | relative_url -%}
-            {%- endif -%}
-            <a href="{{ node.url | relative_url }}" class="navigation-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a>
-            {%- if node.has_children -%}
-              {%- assign children_list = pages_list | where: "parent", node.title -%}
-              <ul class="navigation-list-child-list ">
-                {%- for child in children_list -%}
-                {%- unless child.nav_exclude -%}
-                  <li class="navigation-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
-                    {%- if page.url == child.url or page.parent == child.title -%}
-                      {%- assign second_level_url = child.url | relative_url -%}
-                    {%- endif -%}
-                    <a href="{{ child.url | relative_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
-                    {%- if child.has_children -%}
-                        {%- assign grand_children_list = pages_list | where: "parent", child.title | where: "grand_parent", node.title -%}
-                        <ul class="navigation-list-child-list">
-                        {%- for grand_child in grand_children_list -%}
-                          <li class="navigation-list-item {% if page.url == grand_child.url %} active{% endif %}">
-                            <a href="{{ grand_child.url | relative_url }}" class="navigation-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
-                          </li>
-                        {%- endfor -%}
-                      </ul>
-                    {%- endif -%}
-                  </li>
-                {%- endunless -%}
-                {%- endfor -%}
-              </ul>
-            {%- endif -%}
-          </li>
-        {%- endif -%}
-      {%- endunless -%}
-    {%- endfor -%}
-  </ul>
-</nav>
+<ul class="nav-list">
+  {%- assign ordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order != nil" -%}
+  {%- assign unordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order == nil" -%}
+  {%- if site.nav_sort == 'case_insensitive' -%}
+    {%- assign sorted_ordered_pages_list = ordered_pages_list | sort_natural:"nav_order" -%}
+    {%- assign sorted_unordered_pages_list = unordered_pages_list | sort_natural:"title" -%}
+  {%- else -%}
+    {%- assign sorted_ordered_pages_list = ordered_pages_list | sort:"nav_order" -%}
+    {%- assign sorted_unordered_pages_list = unordered_pages_list | sort:"title" -%}
+  {%- endif -%}
+  {%- assign pages_list = sorted_ordered_pages_list | concat: sorted_unordered_pages_list -%}
+  {%- for node in pages_list -%}
+    {%- unless node.nav_exclude -%}
+      {%- if node.parent == nil and node.title -%}
+        <li class="nav-list-item{% if page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}">
+          {%- if page.parent == node.title or page.grand_parent == node.title -%}
+            {%- assign first_level_url = node.url | relative_url -%}
+          {%- endif -%}
+          {%- if node.has_children -%}
+            <a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a>
+          {%- endif -%}
+          <a href="{{ node.url | relative_url }}" class="nav-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a>
+          {%- if node.has_children -%}
+            {%- assign children_list = pages_list | where: "parent", node.title -%}
+            <ul class="nav-list ">
+            {%- for child in children_list -%}
+              {%- unless child.nav_exclude -%}
+                <li class="nav-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
+                  {%- if page.url == child.url or page.parent == child.title -%}
+                    {%- assign second_level_url = child.url | relative_url -%}
+                  {%- endif -%}
+                  {%- if child.has_children -%}
+                    <a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a>
+                  {%- endif -%}
+                  <a href="{{ child.url | relative_url }}" class="nav-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
+                  {%- if child.has_children -%}
+                    {%- assign grand_children_list = pages_list | where: "parent", child.title | where: "grand_parent", node.title -%}
+                    <ul class="nav-list">
+                    {%- for grand_child in grand_children_list -%}
+                      <li class="nav-list-item {% if page.url == grand_child.url %} active{% endif %}">
+                        <a href="{{ grand_child.url | relative_url }}" class="nav-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
+                      </li>
+                    {%- endfor -%}
+                    </ul>
+                  {%- endif -%}
+                </li>
+              {%- endunless -%}
+            {%- endfor -%}
+            </ul>
+          {%- endif -%}
+        </li>
+      {%- endif -%}
+    {%- endunless -%}
+  {%- endfor -%}
+</ul>
diff --git a/lib/tasks/search.rake b/lib/tasks/search.rake
index 163fb03a732de59cf4b3a7490ba0382eb1ae0a1d..6b0900ef96704931f0ec289fe3c5e07805f69e65 100644
--- a/lib/tasks/search.rake
+++ b/lib/tasks/search.rake
@@ -3,23 +3,68 @@ namespace :search do
   task :init do
     puts 'Creating search data json file...'
     mkdir_p 'assets/js'
-    touch 'assets/js/search-data.json'
-    content = %Q[{{ page.content | markdownify | replace: '</h', ' . </h' | replace: '<hr', ' . <hr' | replace: '</p', ' . </p' | replace: '</ul', ' . </ul' | replace: '</tr', ' . </tr' | replace: '</li', ' | </li' | replace: '</td', ' | </td' | strip_html | escape_once | remove: 'Table of contents' | remove: '```'  | remove: '---' | replace: '\\', ' ' | replace: ' .  .  . ', ' . ' | replace: ' .  . ', ' . ' | normalize_whitespace }}]
+    touch 'assets/js/zzzz-search-data.json'
     puts 'Done.'
     puts 'Generating content...'
 
-    File.open('assets/js/search-data.json', 'w') do |f|
+    File.open('assets/js/zzzz-search-data.json', 'w') do |f|
       f.puts '---
+permalink: /assets/js/search-data.json
 ---
 {
-  {% assign comma = false %}
-  {% for page in site.html_pages %}{% if page.search_exclude != true %}{% if comma == true%},{% endif %}"{{ forloop.index0 }}": {
-    "title": "{{ page.title | replace: \'&amp;\', \'&\' }}",
-    "content": "'+content+'",
+  {%- assign i = 0 -%}
+  {% for page in site.html_pages %}
+    {%- if page.title and page.search_exclude != true -%}
+      {%- assign page_content = page.content -%}
+      {%- assign heading_level = site.search.heading_level | default: 2 -%}
+      {%- for j in (2..heading_level) -%}
+        {%- assign tag = \'<h\' | append: j -%}
+        {%- assign closing_tag = \'</h\' | append: j -%}
+        {%- assign page_content = page_content | replace: tag, \'<h1\' | replace: closing_tag, \'</h1\' -%}
+      {%- endfor -%}
+      {%- assign parts = page_content | split: \'<h1\' -%}
+      {%- assign title_found = false -%}
+      {% for part in parts offset: 1 %}
+        {%- assign titleAndContent = part | split: \'</h1>\' -%}
+        {%- assign title = titleAndContent[0] | replace_first: \'>\', \'<h1>\' | split: \'<h1>\' -%}
+        {%- assign title = title[1] | strip_html -%}
+        {%- assign content = titleAndContent[1] -%}
+        {%- assign url = page.url -%}
+        {%- if title == page.title and parts[0] == \'\' -%}
+          {%- assign title_found = true -%}
+        {%- else -%}
+          {%- assign id = titleAndContent[0] -%}
+          {%- assign id = id | split: \'id="\' -%}
+          {%- if id.size == 2 -%}
+            {%- assign id = id[1] -%}
+            {%- assign id = id | split: \'"\' -%}
+            {%- assign id = id[0] -%}
+            {%- capture url -%}{{ url | append: \'#\' | append: id }}{%- endcapture -%}
+          {%- endif -%}
+        {%- endif -%}
+  {%- unless i == 0 -%},{%- endunless -%}
+  "{{ i }}": {
+    "doc": {{ page.title | jsonify }},
+    "title": {{ title | jsonify }},
+    "content": {{ content | replace: \'</h\', \' . </h\' | replace: \'<hr\', \' . <hr\' | replace: \'</p\', \' . </p\' | replace: \'<ul\', \' . <ul\' | replace: \'</ul\', \' . </ul\' | replace: \'<ol\', \' . <ol\' | replace: \'</ol\', \' . </ol\' | replace: \'</tr\', \' . </tr\' | replace: \'<li\', \' | <li\' | replace: \'</li\', \' | </li\' | replace: \'</td\', \' | </td\' | replace: \'<td\', \' | <td\' | replace: \'</th\', \' | </th\' | replace: \'<th\', \' | <th\' | strip_html | remove: \'Table of contents\' | normalize_whitespace | replace: \'. . .\', \'.\' | replace: \'. .\', \'.\' | replace: \'| |\', \'|\' | append: \' \' | jsonify }},
+    "url": "{{ url | relative_url }}",
+    "relUrl": "{{ url }}"
+  }
+        {%- assign i = i | plus: 1 -%}
+      {%- endfor -%}
+      {%- unless title_found -%}
+  {%- unless i == 0 -%},{%- endunless -%}
+  "{{ i }}": {
+    "doc": {{ page.title | jsonify }},
+    "title": {{ page.title | jsonify }},
+    "content": {{ parts[0] | replace: \'</h\', \' . </h\' | replace: \'<hr\', \' . <hr\' | replace: \'</p\', \' . </p\' | replace: \'<ul\', \' . <ul\' | replace: \'</ul\', \' . </ul\' | replace: \'<ol\', \' . <ol\' | replace: \'</ol\', \' . </ol\' | replace: \'</tr\', \' . </tr\' | replace: \'<li\', \' | <li\' | replace: \'</li\', \' | </li\' | replace: \'</td\', \' | </td\' | replace: \'<td\', \' | <td\' | replace: \'</th\', \' | </th\' | replace: \'<th\', \' | <th\' | strip_html | remove: \'Table of contents\' | normalize_whitespace | replace: \'. . .\', \'.\' | replace: \'. .\', \'.\' | replace: \'| |\', \'|\' | append: \' \' | jsonify }},
     "url": "{{ page.url | relative_url }}",
     "relUrl": "{{ page.url }}"
-  }{% assign comma = true %}
-  {% endif %}{% endfor %}
+  }
+        {%- assign i = i | plus: 1 -%}
+      {%- endunless -%}
+    {%- endif -%}
+  {% endfor %}
 }'
     end
     puts 'Done.'