# Manually knitting an Rmd file produces different results when the file is located at different places

When writing a blog post, I often manually knit the document to examine the results (figures, latex formula) quickly, and the output used to be a normal html_document which suits my need. However, after a recent update, manually knitting the document under a blogdown directory no longer produces the html_document output. Instead, it produces something like the following where figures and latex formulas aren't shown properly (taking the default content of an Rmd file as an example):

Here's the output of the "R Markdown" console in RStudio:

/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS 1.knit.md
--to html4
--output 1.html~
--lua-filter /usr/local/lib/R/site-library/bookdown/rmarkdown/lua/custom-environment.lua
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/latex-div.lua
--standalone
--section-divs
--template /usr/local/lib/R/site-library/blogdown/resources/template-minimal.html
--no-highlight
--mathjax


If I knit the same document outside a blogdown directory, then the resulting output is as expected:

And the output of the "R Markdown" console is:

/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS 1.knit.md
--to html4
--output 1.html
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/latex-div.lua
--self-contained
--variable bs3=TRUE
--standalone
--section-divs
--template /usr/local/lib/R/site-library/rmarkdown/rmd/h/default.html
--no-highlight
--variable highlightjs=1
--variable theme=bootstrap
--mathjax
--variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML


What happens when I click the "knit" button in RStudio? How to adjust the behaviour so that when knitting the document in a blogdown directory produces an html_output file?

The first screenshort shows that the YAML header was not really correctly parsed. Please check it.

Also with blogdown, you can run the check functions. See about them here: Announcing blogdown v1.0 | RStudio Blog

Then, with Blogdown, you can preview your site while working on it. No need to compile to html_document(). This is better practice to preview your post in its blog context. And I guess that would prevent some errors.