0

I am trying to embed a survey form in a rmarkdown on distill blog. As far as I understand, distill converts the rmarkdown to html in docs. I have put my HTML code directly into rmarkdown and it's sort of working.

However, whenever I click the distill page, it will have to load the rmarkdown-knitted blank page first before popping up the embedded HTML survey. My suspection about this lagging is on the YAML setting. Is there a way to set the rmarkdown to render the embedded HTML content directly? Obviously, I can just put an HTML file in the doc so it renders smoothly but it will be deleted after rebuilding the website.

---
title: "Survey"
output:
  distill::distill_article:
    self_contained: true
---

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
</head>
<body>
<script>

survey form 

</script>
</body>
</html>
codedancer
  • 1,504
  • 9
  • 20
  • I answered a similar question regarding distill articles [here](https://stackoverflow.com/questions/64912977/how-to-embed-external-html-in-r-distill-rmd) try this solution by having the HTML file in the same directory as the .Rmd file, and using the `htmltools::includeHTML("test.html")` with the `htmltools` library, let me know if that works or not and I can try answering your question further – Daniel_j_iii Feb 25 '21 at 13:54
  • Thanks. It's still the same as I pasted the HTML code directly into rmarkdown. It shows up but it would go to the knitted rmarkdown first before popping into the natual HTML code. I guess it's the lagging or delay annoying me. I guess I can live with it if there's no way to overcome. The annoying thing is that whenver I place a html file in distill folder, it's gone missing after the knitting. It feels like there's an invisible monster eating my HTML file! – codedancer Feb 25 '21 at 19:52
  • When you render the distill article file, go to the "_site" directory, that is where your HTML file gets stashed at I think, for hosting purposes – Daniel_j_iii Feb 26 '21 at 01:10

0 Answers0