diff --git a/templates/html.template b/templates/html.template
index 820279939..1d07a2cfb 100644
--- a/templates/html.template
+++ b/templates/html.template
@@ -41,12 +41,12 @@ $for(header-includes)$
 $endfor$
 </head>
 <body>
-$if(title)$
-<h1 class="title">$title$</h1>
-$endif$
 $for(include-before)$
 $include-before$
 $endfor$
+$if(title)$
+<h1 class="title">$title$</h1>
+$endif$
 $if(toc)$
 $toc$
 $endif$
diff --git a/tests/s5.inserts.html b/tests/s5.inserts.html
index 0af12ffaa..69ab6f5e1 100644
--- a/tests/s5.inserts.html
+++ b/tests/s5.inserts.html
@@ -11,8 +11,8 @@
   STUFF INSERTED
 </head>
 <body>
-<h1 class="title">My S5 Document</h1>
 STUFF INSERTED
+<h1 class="title">My S5 Document</h1>
 <div id="first-slide"
 ><h1
   >First slide</h1