4

I have a personal blog created via blogdown. I started a new entry (after a long time) via the command:

blogdown::new_post(title="article-r", author="Me", 
               categories=c("data-science", "stats"), 
               date=Sys.Date(), 
               tags=NULL, 
               ext=".Rmd")

This led to a new Rmd file:

content/post/2018-08-15-article-r.Rmd

Now I ran the following to build the site and serve it in RStudio

blogdown::build_site(local = FALSE, method = c("html"))
blogdown::serve_site()

After building, the page does create an html file in content/post:

Rendering content/post/2018-08-15-article-r.Rmd

This seems good, but I can't see the new post served up in the RStudio viewer pane. Also I can't see the post appear cached in the cd blogdown/post/ folder.

Could anyone please assist me in ensuring the post is appropriately cached and render it in the viewer pane when running serve_site()

user4687531
  • 1,021
  • 15
  • 30
  • For me I've found I often don't see the updated preview within RStudio after I "serve site" until I make a new edit to the .Rmd file. – aosmith Aug 16 '18 at 17:11
  • @aosmith - thanks. Though I've made several edits now, saved build site repeatedly and serve_site() as well. The new post just doesn't seem to get displayed – user4687531 Aug 16 '18 at 17:42
  • Just to be clear, my algorithm is usually to write or start a post, serve the site, and then make an edit and save the Rmd file again. Only then do I see the changes in my Viewer. (Note I'm using `blogdown.generator.server = TRUE`). If I make edits in a session before serving the site, I can't see them until I edit and save once I "serve site". – aosmith Aug 16 '18 at 18:22
  • where do you set the `blogdown.generator.server = TRUE` argument? – user4687531 Aug 16 '18 at 18:23
  • I have this set as my default options in my .Rprofile, but you can set it in a session by running `options(blogdown.generator.server = TRUE)` in the console (I think this may be most useful for Windows, but could be mistaken). There is info in the blogdown book about this option, but don't have time to look it up at the moment. – aosmith Aug 16 '18 at 18:38
  • By creating a post, if the `post` directory doesn't exists it will create this directory. Is there another directory in your `content` directory besides `post`? I had some issue with some Hugo themes and I had to put my `Rmd` files in directories that already exist in `content`. Then I `serve_site()` and it worked for me. P.S.: I haven't tried with Icon Theme. – patL Aug 18 '18 at 14:36
  • can you share your website sources in a github repo maybe? – TC Zhang Aug 23 '18 at 23:40

2 Answers2

0

Blogdown can be frustrating. The correct workflow (I believe) is to run blogdown::serve_site() first, then create your new post with blogdown::new_post(title ="title"). I just checked on my blog and the Viewer updates with the new post.

This blog by Alison Hill is helpful: https://alison.rbind.io/post/up-and-running-with-blogdown/.

Good luck!

Nick
  • 417
  • 4
  • 14
  • thanks - tho this is not working for me. The problem is only posts that are appearing in `blogdown/post/` are rendering. Nothing is being cached in this folder for any new posts. I am seeing the `html` files appear in `content/post` however – user4687531 Aug 16 '18 at 18:24
  • It is difficult to answer exactly. To be sure, did you restart Rstudio and then try the method I suggested? – Nick Aug 16 '18 at 18:33
  • Thanks. I retried - unfortunately still not working. – user4687531 Aug 16 '18 at 22:47
0

Confirm that your markdown file includes a chunk that loads the blogdown package. If not, the file will knit correctly and you will have the appropriate HTML in your content folder, but blogdown won't integrate it into the site. I was having the same issue, then added blogdown to my list of libraries to load, and it was available on the local server as soon as I saved the file again.

mae
  • 121
  • 4