diff --git a/application/source/document/html.go b/application/source/document/html.go
index 12e0c8bc0d2c201e3060bbd8c8f94346d16984b6..1bbc2de1b8575c8bbf6760927b3c7ac90c4d2a73 100644
--- a/application/source/document/html.go
+++ b/application/source/document/html.go
@@ -170,6 +170,9 @@ func extractTemplate(env *BuildHtmlEnvironment, doc *html.Node, id string) {
 	checkError(err)
 
 	node := cascadia.Query(doc, sel)
+	if node == nil {
+		return
+	}
 	node.Parent.RemoveChild(node)
 
 	container := html.Node{