rmarkdown within distill not rendering ggplot image

Hi! I am using distill to generate blogposts with R Markdown files. Can anyone help me troubleshoot why a ggplot image is not rendering?

See blog post here, with image below.
image

Source .Rmd file is here

I have been experimenting with different options in yaml, not sure if that affected things.

Many thanks!

Which version of rmarkdown an distill do you have ? Thanks !

Apologies, that would have been helpful! I am using distill 0.8, and I just upgraded to rmarkdown 2.4 (and re-rendered blog plost and re-built website, still same).

For the yaml options I was playing with:

  • in _site.yml: true/fase
rss:
  full_content: false
  • post yaml: true/false
output:
  distill::distill_article:
    self_contained: false

I can't think of anything else that I touched (I think it did render correctly before I messed with those).

And this from the Build window would probably be helpful as well - looks like item 2 may be the culprit.

Output created: _site/index.html
Warning messages:
1: In file.copy(from = file.path(dirname(article$path), rmd_resources),  :
  problem copying .\_posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\distill-2.2.21\template.v2.js to .\_site\posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\distill-2.2.21\template.v2.js: No such file or directory
2: In file.copy(from = file.path(dirname(article$path), rmd_resources),  :
  problem copying .\_posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\figure-html5\unnamed-chunk-3-1.png to .\_site\posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\figure-html5\unnamed-chunk-3-1.png: No such file or directory
3: In file.copy(from = file.path(dirname(article$path), rmd_resources),  :
  problem creating directory .\_site\posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\header-attrs-2.3: No such file or directory
4: In file.copy(from = file.path(dirname(article$path), rmd_resources),  :
  problem creating directory .\_site\posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\header-attrs-2.4: No such file or directory
5: In file.copy(from = file.path(dirname(article$path), rmd_resources),  :
  problem creating directory .\_site\posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\webcomponents-2.0.0: No such file or directory

it seems so. It does not manage to move files to the site location. That is strange !

Does this file exist after you render the post ?

the png does exist in the _posts folder:

\pipinghotdata_distill\_posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\figure-html5

but does not exist in the mirrored _site folder

\pipinghotdata_distill\_site\posts\2020-09-22-exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr\exporting-editable-ggplot-graphics-to-powerpoint-with-officer-and-purrr_files\figure-html5

So this is an issue with the copying.

Just a guess: I know windows (and R) has sometimes difficulties when the path is really long. And I notice in you case you have a very long file name and folder name.

Can you try by shorthening the name to see if it works ?

See https://rstudio.github.io/distill/blog.html#renaming-posts and https://rstudio.github.io/distill/blog_workflow.html#renaming-posts

You also can use a slug field in your yaml header of the post I think so that it is use as permalink

Just an idea though, not sure it is related, but that is worth a try right ?

Thank you for the suggestion! And yes, I do think I have gotten weird errors for other posts when names are too long and/or different types of punctuation in the title.

I'm pretty sure for this post the image did render correctly when originally published - but then I messed a couple of yaml option in different places (trying to modify RSS feed) and pushed to git without noticing the image not rendering.

If I rename the post, won't that change the slug and the url? So if that is the solution, then the links up to the published blog post break?

Is it worth trying just deleting nearly everything except the .Rmd and re-rendering? If so, would you delete the corresponding folder under _site as well and re-build?

I would follow the docs I linked on that matter but yes I think it would change the url.

You can but if this is an issue with Windows and Long Path Names then it will be the same. if you have everything on Git, you can try rendering in Linux (on RStudio cloud for example) to see if this is Windows related as I think. On windows, you can also move the project folder somewhere closer to root of your computer so that the path of a file is shortened.

I think yes you could delete this folder and it would be recreated when rebuilding. Anyway, I am not an expert on Distill - be safe with what you are doing. If you use Git, you have a security I believe.

I would make a local copy of everything (belt and suspenders) but you should be safe to delete _site/ and rebuild from scratch.

1 Like

Thanks for chiming in! I did delete _site/ as well as ..._files in the post and re-render the rmarkdown and rebuild the site, and the problem remains. ¯\_(ツ)_/¯ I might just let this one go!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.