diff --git a/trypandoc/index.html b/trypandoc/index.html
index ea7cacc2d..2b42ab179 100644
--- a/trypandoc/index.html
+++ b/trypandoc/index.html
@@ -32,8 +32,9 @@ function newpage() {
   var input = $("#text").val();
   var from = $("#from").val();
   var to = $("#to").val();
+  var standalone = $("#standalone").is(':checked') ? "1" : "0";
   var href = window.location.href;
-  window.location.href = href.replace(/([?].*)?$/,"?" + $.param({text: input, from: from, to: to}));
+  window.location.href = href.replace(/([?].*)?$/,"?" + $.param({text: input, from: from, to: to, standalone: standalone}));
 };
 
 $(document).ready(function() {
@@ -43,8 +44,10 @@ $(document).ready(function() {
     $("#from").val(from);
     var to = $.QueryString["to"] || "html";
     $("#to").val(to);
+    var standalone = ($.QueryString["standalone"] === "1") ? "1" : "0"
+    $("#standalone").prop('checked', (standalone === "1"));
     if (text && text != "") {
-       $.getJSON("/cgi-bin/trypandoc", { from: from, to: to, text: text },
+       $.getJSON("/cgi-bin/trypandoc", { from: from, to: to, text: text, standalone: standalone },
          function(res) {
           $("#results").text(res.html);
           $("#version").text(res.version);
@@ -116,6 +119,10 @@ $(document).ready(function() {
         <option value="twiki">TWiki</option>
         <option value="vimwiki">Vimwiki</option>
       </select>
+      <input type="checkbox" id="standalone" name="standalone">
+      <label for="standalone">Generate standalone document
+        <a href="https://pandoc.org/MANUAL.html#option--standalone" target="_blank">(?)</a>
+      </label>
       <br/>
       <textarea id="text" maxlength="3000" rows="15"></textarea>
     </div>
diff --git a/trypandoc/trypandoc.hs b/trypandoc/trypandoc.hs
index 2e4797669..f56a00ac5 100644
--- a/trypandoc/trypandoc.hs
+++ b/trypandoc/trypandoc.hs
@@ -41,6 +41,9 @@ app req respond = do
   text <- getParam "text" >>= checkLength . fromMaybe T.empty
   fromFormat <- fromMaybe "" <$> getParam "from"
   toFormat <- fromMaybe "" <$> getParam "to"
+  standalone <- (==) "1" . fromMaybe "" <$> getParam "standalone"
+  compiledTemplate <- runIO . compileDefaultTemplate $ toFormat
+  let template = if standalone then either (const Nothing) Just compiledTemplate else Nothing
   let reader = case runPure $ getReader fromFormat of
                     Right (TextReader r, es) -> r readerOpts{
                        readerExtensions = es }
@@ -48,7 +51,7 @@ app req respond = do
                                   ++ T.unpack fromFormat
   let writer = case runPure $ getWriter toFormat of
                     Right (TextWriter w, es) -> w writerOpts{
-                       writerExtensions = es }
+                       writerExtensions = es, writerTemplate = template }
                     _ -> error $ "could not find writer for " ++
                            T.unpack toFormat
   let result = case runPure $ reader (tabFilter 4 text) >>= writer of