Local preview of draft posts does not work

404 Views Asked by At

I tried to reproduce (and understand) Appendix C.3 Building a website for local preview of the blogdown book:

I have demonized the server successfully in my ~/.Rprofile with

options(servr.daemon = TRUE)
  • Whenever I run blogdown::serve_site() those markdown files (.md) which are marked with draft: yes in their yaml-header do not appear at http://127.0.0.1:4321/ (or whatever the address of the local server is). If I change to draft: no they do appear. But in my understanding, all files should appear on the local website.
  • If i build the site with the menu 'Build Website' via GitHub and Netlify the draft: yes posts do not appear (= correct behavior)
  • If I use hugo -D from the terminal, everything works as expected; `draft: yes' file do appear! But this works (as anticipated) only with .md files (not with .Rmd files).

At the moment I have to change the draft status every time I want to inspect the file locally with the danger that I forget to set it back to draft: yes and publish those files inadvertently on my live site.

So how can I see and edit draft: yes files on the local server?

1

There are 1 best solutions below

2
On BEST ANSWER

With blogdown 0.1 and your example at https://github.com/petzi53/test-academic-theme, I had to remove the comment after baseurl in config.toml, i.e., change

baseurl = "/"  # End your URL with a `/` trailing slash.

to

baseurl = "/"

Then I ran blogdown::serve_site(), and I can see the draft post:

site preview

The issue with comments has been fixed in the development version of blogdown on Github.