Serve_site() creates index of site, rather than site preview - blogdown



Split from Blogdown serve_site() returns index of site, rather than site preview

Does not appear to be a themeissue

I have the same problem and it has nothing to do with a missing theme. I hope that it is easy to reproduce:

  1. Method: I follow the recommended workflow of the blogdown book:

After creating a new project in RStudio, I type into the console the code
blogdown::new_site(theme = 'gcushen/hugo-academic')

The system answered:

blogdown::new_site(theme = 'gcushen/hugo-academic')
trying URL ''
downloaded 1.2 MB

Rendering content/post/2015-07-23-r-rmarkdown.Rmd

And I got immediately the index of the site. I could not manage to see the html version of the site.

  1. Method: Creating a Rstudio project with "Creating a new website with Hugo and blogdown"

I wrote in the field "Hugo theme": gcushen/hugo-academic and left all the other fields unchanged. The system answered:

trying URL ''
Content type 'application/zip' length 1294225 bytes (1.2 MB)
downloaded 1.2 MB


and restarted R.

Now I can observe the following problems:

  • When I tried blogdown::serve_site() I got the index of the site.
  • When I tried I the „Build Website“ button I got ~/Documents/Meine-Repos/Test-Repos/test-academic/public/index.html not found
  • When I tried More -> "CleanAll" I got
Removing files: 

and in the viewer pane: ERROR: cannot change working directory

Maybe it has to do with the path and/or the .Rmd files. When I deleted all .Rmd files of a previous working hugo-academic installation I succeeded to return to the to the website with blogdown:::serve_site().

After deleting all .Rmd files in the virgen hugo-academic installation the error message of the "Clean All" button changed to:

==> rmarkdown::clean_site()

Error in file.exists(files) : invalid 'file' argument
Calls: <Anonymous> -> <Anonymous> -> clean_targets -> file.exists
Execution halted

Exited with status 1.

Here is my sessionInfo():

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.5

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.5/Resources/lib/libRlapack.dylib

[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     

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17    bookdown_0.7    later_0.7.3     digest_0.6.15   rprojroot_1.3-2
 [6] R6_2.2.2        backports_1.1.2 magrittr_1.5    evaluate_0.10.1 blogdown_0.8   
[11] stringi_1.2.3   rstudioapi_0.7  promises_1.0.1  rmarkdown_1.10  tools_3.5.1    
[16] servr_0.10      stringr_1.3.1   rsconnect_0.8.8 httpuv_1.4.4.2  xfun_0.3       
[21] yaml_2.1.19     compiler_3.5.1  htmltools_0.3.6 knitr_1.20

I have tried all this out with the hugo-academic version 2.3 (July 2018)

Any help would very much appreciated.

Blogdown serve_site() returns index of site, rather than site preview

In the meanwhile I have tried all the above steps with the hugo-lithium theme and did not run into any problems. So it has to do with the interplay between blogdown and the hugo-academictheme. And as it used to work: it has to be a problem with the new versions.

Maybe there is some terrible wrong on my site (but I doubt it). It seems to me an incompatibility. If someone can reproduce the same problem maybe I should report it on StackOverflow or on the blogdown repo so that Yihui Xie could have a look into it?


I tried to deploy the site with netlify anyway to see what error messages would be created. I' ve got

10:22:48 AM: ERROR 2018/07/17 08:22:48 Failed to render "_default/single.html": runtime error: invalid memory address or nil pointer dereference

The repo of this website is at petzi53/test-academic2 and here is the link to the log file of netlify.


The academic theme is structured in a manner that's quite different from other themes (I don't use it, but I've helped a few people troubleshoot with it). I'm not sure if it will help your issue, but there was a recent blog post with tips specific to dealing with academic that you might take a look at:

Is it possible that you haven't set up your config to point to the desired directory correctly? Also, blogdown::serve_site() is a perfectly fine way to do your build (I've never actually hit the "Build website" button), so if that's working fine, then using serve_site() might be the way to go.

It sounds like you've tried most options, but see also my response here:

You can see what artifacts you may have created by looking in the git pane.


@mara thank you for your detailed reply. I am afraid that your tips will not help me as I have read already and followed these posts mentioned by you. I have to confess that I am not a complete newcomer to blogdown and – like you – I am in the custom to use always blogdown:::serve_site() (CTRL-S on my machine, applying the RStudio addin "Serve Site"). I just wanted to mentioned what else I have tried out. - I am not using the knit button.

The problem appeared after I updated blogdown and the academic theme and used the menue button "Build" -> "More…" -> "Clean All". As I do not many time "Clean All" I cannot say exactly which change – or which update – caused the problem. But fact is: If I try to install the academic theme from scratch – as I have described with creating a new RStudio project – it does not work anymore.

Any idea what I could try next?


Hmm, a trifecta of changes! That is tricky…

I would try to isolate the changes. If you're installing from github, you can use devtools::install_github() and specify the release tag, branch name, or even pull request from which you want to install. (You can do the same from many GitHub clients if you're downloading a repo that's not an R package — e.g. an older version of the academic theme).

For example, if you wanted to go back to blogdown 0.6.0 and see if things worked with the current academic version paired with the old blogdown version you'd do:


If you're working from a GitHub repo, you can also roll back the changes you've made to your last working version and/or use git cherry pick to keep content changes (if any), but not other changes you've made.

I definitely recommend creating git branches so you can play around without doing anything to your master branch.


Ah thanks!! Roll back the changes is a great idea! How embarrassing that I didn't come up with this idea myself. I will report the results here.


After rolling back blogdown and the hugo-academic theme it turned out:

  • blogdown is fine!
  • the problem was introduced with version hugo-academic-2.2.0. That means: 2.1.0 works fine but the versions 2.2.0 and 2.3.0. display my reported wrong behavior.

I will report this problem to @gcushen.

I want to thank you again for your help!! It is motivating to talk to someone about emerging problems. I like the atmosphere here on this forum because it is not so stressful / intimidating as in StackOverflow.


:tada: I'm glad you sorted it out! It seems like the hugo-academic repo is quite active (I know it's a popular theme), so prospects are good.


The answer by @gcushen:

... it appears unrelated to the Academic code. Academic works fine when used directly with Hugo. Since the problem only occurs with Blogdown and based on your comments and the fact that Blogdown acts as a wrapper around Hugo, it would appear that there may be a bug in Blogdown.

So I reported the issue in the blogdown repo.


:+1: Good to know. Please keep us updated if/when it gets resolved!


Everything works fine again! With some help by Yihui Xie the issue was solved yesterday by George Cushen. Lastly, it turned out that it was not version 2.2 but 2.3 which introduced the problem. And it was neither a problem with blogdown nor with the academic theme but with

the example site and how Hugo parses it. (@gcushen)

I did not understand completely what went wrong (It's developer talk :sunglasses:).