-# Write first part of entry head.
-cat << EOF
-<!DOCTYPE html>
-<html>
-<head>
-EOF
-
-# Write remaining entry head and body.
-printf "<title>%s – %s</title>\n</head>\n<body>\n" "$blog_title" "$title_plaintext_escaped"
-#printf "<title>%s – %s</title>\n</head>\n<body>\n" "$blog_title" "$entry_title"
-printf "<h1>%s</h1>\n" "$title_html"
-printf "<section>\n%s\n</section>\n</body>\n</html>" "$body"
+# Put data into template.
+template=$(cat "$template_file")
+printf "%s" "$template" | \
+sed 's/%BLOG_TITLE%/'"$blog_title"'/g' | \
+sed 's/%ARTICLE_TITLE_ESCAPED%/'"$title_plaintext"'/g' | \
+sed 's/%ARTICLE_TITLE_HTML%/'"$title_html"'/g' | \
+sed 's/%BODY%/'"$body"'/g' | \
+tr '\a' '%'