diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index c99b45e6..565709b4 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -149,6 +149,51 @@
{{- end }}
+{{- /* theme-toggle is enabled */}}
+{{- if (not site.Params.disableThemeToggle) }}
+{{- /* theme is light */}}
+{{- if (eq site.Params.defaultTheme "light") }}
+
+{{- /* theme is dark */}}
+{{- else if (eq site.Params.defaultTheme "dark") }}
+
+{{- else }}
+{{- /* theme is auto */}}
+
+{{- end }}
+{{- /* theme-toggle is disabled and theme is auto */}}
+{{- else if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark"))}}
+
+{{- end }}
+
{{- partial "extend_head.html" . -}}
{{- /* Misc */}}
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 25c58f2b..e3eb7977 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -1,48 +1,3 @@
-{{- /* theme-toggle is enabled */}}
-{{- if (not site.Params.disableThemeToggle) }}
-{{- /* theme is light */}}
-{{- if (eq site.Params.defaultTheme "light") }}
-
-{{- /* theme is dark */}}
-{{- else if (eq site.Params.defaultTheme "dark") }}
-
-{{- else }}
-{{- /* theme is auto */}}
-
-{{- end }}
-{{- /* theme-toggle is disabled and theme is auto */}}
-{{- else if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark"))}}
-
-{{- end }}
-