rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.73k stars 335 forks source link

Including figures using Knitr #477

Closed dayabin closed 4 years ago

dayabin commented 4 years ago

I am trying to embed figures in my post with blogdown. I am using the hugo academic template. It appears that inserting figures via Addins works, however knitr::include_graphics did not.

knitr::include_graphics("/post/2020-09-24-blogdownwebsite.en_files/plot1.png")

It returned me an error indicating:

Cannot find the file(s): /post/2020-09-24-blogdownwebsite.en_files/plot1.png

I have already placed the figure plot1.png in the above folder (that is static/post/2020-09-24-blogdownwebsite.en_files).

Can someone help me with this issue? Thanks in advance.



By filing an issue to this repo, I promise that

dayabin commented 4 years ago

Problem solved with the code below. All you need is to set the error=F. See similar issues here and here

knitr::include_graphics("/post/2020-09-24-blogdownwebsite.en_files/plot1.png", error = F)