RobertMc RobertMc - 3 years ago 135
R Question

clarity on publishing drafts with Blogdown

Could anyone clarify this for me? If I use

blogdown::build_site()
, blogdown will compile all the
.Rmd
files I have in the website directory, something I don't want (and I've asked about it here).

This being the case, Yihui has recommended using
blogdown::serve_site()
(here and here in the recommended workflow). However,
serve_site()
publishes draft posts, which I obviously don't want published yet.

Judging from here, it seems that something that works is
serve_site()
followed by
hugo_build()
. Is that the correct way to go about it, or am I missing something? Because when I do that, the draft posts don't disappear. Thanks for any suggestions.

Edit: I should mention that running
hugo_build()
by itself doesn't seem to publish any of the
.Rmd
posts.

Answer Source

Per documentation on blogdown::build_site() and serve_site():

  • build_site() and hugo_build() do not build draft or future posts;

  • serve_site() does.

Let me illustrate the differences with a table:

                build draft?    build Rmd?      build which Rmd?
----------------------------------------------------------------
build_site()      NO              YES             ALL
serve_site()      YES             YES             SINGLE (*)
hugo_build()      NO              NO              NONE

(*) Only build the modified Rmd.

If the combination you want is (1) do not build draft, and (2) build only the modified Rmd, there is not a single function to do this, but you can take two steps:

blogdown::build_site(local = TRUE, run_hugo = FALSE)
blogdown::hugo_build()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download