Sebastian Sauer
Sebastian Sauer

Reputation: 1673

How to prevent blogdown from rerendering all posts?

Background:

I am featuring a blog built on @YihuiXie's R package blogdown.

Problem:

When I render_site(), all source files (*.Rmd) are rendered - even the unchanged source files are re-reendered.

This complete re-rendering is time consuming and unnecessary (I think).

Question/ Desired Solution:

How can I prevent blogdown from re-rendering the unchanged source files? I want blogdown to render only new or changed source files.

What I have already tried:

SessionInfo():

R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.4

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.1.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17    rstudioapi_0.7  knitr_1.20      magrittr_1.5    RcppTOML_0.1.3  xtable_1.8-2    R6_2.2.2        rlang_0.2.0     stringr_1.3.1   tools_3.4.4     xfun_0.1       
[12] miniUI_0.1.1.1  htmltools_0.3.6 yaml_2.1.19     rprojroot_1.3-2 digest_0.6.15   bookdown_0.7    later_0.7.2     promises_1.0.1  evaluate_0.10.1 mime_0.5        rmarkdown_1.9.4
[23] blogdown_0.6    stringi_1.2.2   compiler_3.4.4  backports_1.1.2 jsonlite_1.5    httpuv_1.4.3   
> 

Upvotes: 12

Views: 1223

Answers (2)

datistics
datistics

Reputation: 326

blogdown::serve_site() tries to rerender some of my old blog posts after I reset my computer and re-downloaded the code from github.

By using blogdown:::build_rmds("content/post/{file_name}.Rmd") I was able to render single Rmd files to html. To check the results I run hugo server in the terminal window.

Upvotes: 1

Yihui Xie
Yihui Xie

Reputation: 30114

I think the answer is on the page you referenced -- Section 1.7 of the blogdown book ("A recommended workflow"). It seems it is not clear enough to you, so let me rephrase it:

  1. You should rarely need bookdown::render_site(). You can see that I didn't even mention this function in Section 1.7.

  2. Use blogdown::serve_site(), and it is the only function you need to call if your website is published on Netlify, or any servers that can run the hugo command to build your website on the server side.

  3. If you do not use Netlify, or do not call hugo on the server side, but want to build the site locally and publish the public/ folder manually, call blogdown::hugo_build() before you publish your website.

Since you are using Netlify, the answer is basically blogdown::serve_site(). That is all you need. It does not re-render Rmd files that have not been changed. See the Appendix D.3.

Upvotes: 17

Related Questions