diff --git a/layouts/partials/sidebar-tree.html b/layouts/partials/sidebar-tree.html
new file mode 100644
index 0000000..7fb17ee
--- /dev/null
+++ b/layouts/partials/sidebar-tree.html
@@ -0,0 +1,64 @@
+
+
+{{- define "partials/sidebar/mobile-search" -}}
+
+ {{- partialCached "search.html" . -}}
+
+{{- end -}}
+
+{{- define "partials/sidebar/link" -}}
+ {{- $external := strings.HasPrefix .link "http" -}}
+ {{- $open := .open | default true -}}
+
+ {{- .title -}}
+ {{- with .context }}
+ {{- if or .RegularPages .Sections }}{{ partialCached "sidebar/collapsible-button" . }}{{ end -}}
+ {{ end -}}
+
+{{- end -}}
+
+{{- define "partials/sidebar/tree" -}}
+ {{- if ge .level 4 -}}
+ {{- return -}}
+ {{- end -}}
+
+ {{- $context := .context -}}
+ {{- $page := .page }}
+ {{- $level := .level -}}
+
+ {{- with $items := union .context.RegularPages .context.Sections -}}
+ {{- if eq $level 0 -}}
+ {{- range $items.ByWeight }}
+
+ {{- partial "sidebar/link" (dict "context" . "title" .LinkTitle "link" .RelPermalink) -}}
+ {{- partial "sidebar/tree" (dict "context" . "page" $page "level" (add $level 1)) -}}
+
+ {{- end -}}
+ {{- else -}}
+
+
+ {{- range $items.ByWeight }}
+ {{- $title := .LinkTitle | default .File.BaseFileName -}}
+ -
+ {{- partial "sidebar/link" (dict "context" . "title" $title "link" .RelPermalink) -}}
+ {{- partial "sidebar/tree" (dict "context" . "page" $page "level" (add $level 1)) -}}
+
+ {{- end -}}
+
+
+ {{- end -}}
+ {{- end }}
+{{- end -}}
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index 742a6e4..0f406d5 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -6,7 +6,6 @@
{{- $sidebarClass := cond $disableSidebar (cond $displayPlaceholder "md:hidden xl:block" "md:hidden") "md:sticky" -}}
{{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}}
-{{- $navPages := union $navRoot.RegularPages $navRoot.Sections -}}
{{- $pageURL := $context.RelPermalink -}}
diff --git a/layouts/partials/sidebar/toc.html b/layouts/partials/sidebar/toc.html
index 1006013..a5baf5a 100644
--- a/layouts/partials/sidebar/toc.html
+++ b/layouts/partials/sidebar/toc.html
@@ -1,6 +1,8 @@
{{ $page := . }}
{{ with $page.Fragments.Headings }}
-
+
{{- range . }}
{{- with .Headings }}
{{- range . -}}