diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 198f9a91d7..a1c86e35f0 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -60,14 +60,14 @@
{{ end }}
{{ define "rightsidebar_content" }}
- {{/* in-this-section.html depends on these being reneredc first. */}}
- {{ $related := partial "layouts/related.html" . }}
- {{ $toc := partial "layouts/toc.html" . }}
- {{ if not .Params.hide_in_this_section }}
- {{ partial "layouts/in-this-section.html" . }}
- {{ end }}
- {{ $related }}
- {{ if $.Store.Get "hasToc" }}
- {{ $toc }}
- {{ end }}
+
+ {{ $toc := partial "layouts/toc.html" . }}
+ {{ if $.Store.Get "hasToc" }}
+ {{ $toc }}
+ {{ end }}
+ {{ if not .Params.hide_in_this_section }}
+ {{ partial "layouts/in-this-section.html" . }}
+ {{ end }}
+ {{ partial "layouts/related.html" . }}
+
{{ end }}
diff --git a/layouts/partials/layouts/in-this-section.html b/layouts/partials/layouts/in-this-section.html
index 28e5ed7ebf..48d6510c13 100644
--- a/layouts/partials/layouts/in-this-section.html
+++ b/layouts/partials/layouts/in-this-section.html
@@ -1,11 +1,6 @@
{{- with .CurrentSection.RegularPages }}
- {{ $hasTocOrRelated := or ($.Store.Get "hasToc") ($.Store.Get "hasRelated") }}