diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index 89d2442afa..f5c76a026b 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -1,4 +1,11 @@
{{template "base/head" .}}
+{{$treeNamesLen := len .TreeNames}}
+{{$isTreePathRoot := eq $treeNamesLen 0}}
+{{$showSidebar := $isTreePathRoot}}
+{{$hasTreeSidebar := not $isTreePathRoot}}
+{{$showTreeSidebar := .RepoPreferences.ShowFileViewTreeSidebar}}
+{{$hideTreeSidebar := not $showTreeSidebar}}
+{{$hasAndShowTreeSidebar := and $hasTreeSidebar $showTreeSidebar}}
{{template "repo/header" .}}
@@ -16,13 +23,6 @@
{{template "repo/code/recently_pushed_new_branches" .}}
- {{$treeNamesLen := len .TreeNames}}
- {{$isTreePathRoot := eq $treeNamesLen 0}}
- {{$showSidebar := $isTreePathRoot}}
- {{$hasTreeSidebar := not $isTreePathRoot}}
- {{$showTreeSidebar := .RepoPreferences.ShowFileViewTreeSidebar}}
- {{$hideTreeSidebar := not $showTreeSidebar}}
- {{$hasAndShowTreeSidebar := and $hasTreeSidebar $showTreeSidebar}}