rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.73k stars 335 forks source link

Problem with blogdown::new_site using starter-hugo-academic #638

Closed juniperover closed 3 years ago

juniperover commented 3 years ago

I have posted this issue at the Hugo community here: https://github.com/wowchemy/wowchemy-hugo-modules/issues/2368#issue-936228734

I'm trying to use blogdown (v. 1.3.2) in RStudio (v. 1.4.1717/R version 4.1.0) on Mac Big Sur.

When invoking the new_site command, I get the following error message:

> new_site(theme = "wowchemy/starter-hugo-academic")

― Creating your new site
| Installing the theme wowchemy/starter-hugo-academic from github.com
trying URL 'https://github.com/wowchemy/starter-hugo-academic/archive/master.tar.gz'
downloaded 7.1 MB

trying URL 'https://github.com/wowchemy/wowchemy-hugo-modules/archive/v5.3.0.tar.gz'
downloaded 504 KB

Error: module "github.com/wowchemy/wowchemy-hugo-modules/wowchemy/v5" not found; either add it as a Hugo Module or store it in "/Users/[path-info]/themes".: module does not exist
Error in new_content(f2, open = FALSE) : 
  Failed to create the file 'post/2020-12-01-r-rmarkdown/index.en.Rmd'.
In addition: Warning message:
In system2(find_hugo(), ...) :
  running command ''/Users/[path]/Library/Application Support/Hugo/0.84.4/hugo' new 'post/2020-12-01-r-rmarkdown/index.en.md' --themesDir themes -t starter-hugo-academic' had status 255
> 

It appears that the site contents have been moved around so that a path is broken? Any advice or hope for a fix? TIA.

Here's the requested session info:

R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.4, RStudio 1.4.1717

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  base64enc_0.1.3   blogdown_1.3.2    bookdown_0.22     digest_0.6.27     evaluate_0.14    
  glue_1.4.2        graphics_4.1.0    grDevices_4.1.0   highr_0.9         htmltools_0.5.1.1
  httpuv_1.6.1      jsonlite_1.7.2    knitr_1.33        later_1.2.0       magrittr_2.0.1   
  markdown_1.1      methods_4.1.0     mime_0.11         promises_1.2.0.1  R6_2.5.0         
  Rcpp_1.0.6        rlang_0.4.11      rmarkdown_2.9     servr_0.22        stats_4.1.0      
  stringi_1.6.2     stringr_1.4.0     tinytex_0.32      tools_4.1.0       utils_4.1.0      
  xfun_0.24         yaml_2.2.1       

Hugo version: 0.84.4

Checklist

When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:

-->

sammo3182 commented 3 years ago

Same problem from a Windows system with the dev version of Rstudio. The problem looks common among users. See the discussion starting also by Jen here https://github.com/rbind/apreshill/issues/44#issuecomment-873382800. I used to be a user of the hugo-academic. Now it seems that neither the old version or the wowchemy version can build up the website. Hope a solution soon 🤞

cderv commented 3 years ago

I can confirm this is an issue currently.

For context, Academic is a theme that requires Go to work because it is using Hugo Modules, so officially the installation step have a prerequisite for Go to be installed when working locally : https://wowchemy.com/docs/getting-started/install-hugo-extended/#prerequisites

In blogdown, we have tried to bypass this so that Go is not needed. It was done in https://github.com/rstudio/blogdown/commit/da068a7d8b4b5c923044665de91c21906ca66a11

It seems that it no more works as expected. The Go module in question is correctly downloaded from Github, but it is not extracted correctly because what we expect is not there anymore.

I believe this has to do with a very recent change in hugo academic starter kit. https://github.com/wowchemy/starter-hugo-academic/commit/09b4c21a0bedcbf1718cbb1223dba08ff26aad50#diff-5bed2c958464666aa841aecfa747db471387119abc35bb3fbb729565aaac8818

So I think this is the cause of the issue with bookdown.

We'll look into that

cderv commented 3 years ago

After looking into this, I think it got more complicated to get around the Go requirement to make this theme works asis with blogdown.

Here are some notes on my deep dive into Go modules :)

We need to take into account more cases about how Go modules is handled.

By using both files we should be able to download and install the right thing.

Still a workaround though.

Best thing would be to have a try at following the theme installation instruction with the go requirement. However, blogdown may still lack support for config directory #611

Anyway, i'll keep having a look into this.

jyotishkarc commented 3 years ago

@cderv So, as of now, there's absolutely no way to create a site by blogdown using the Hugo Academic theme ? :( If yes, can someone please write the process in brief ?

cderv commented 3 years ago

The main issue is that the Academic theme requires Go to be installed to create the site. This is because the Hugo theme is a Go module of the starter site (Hugo Modules. blogdown does not handle Go currently and use workaround. The second issue is that the theme is using a config dir, which is not yet supported (https://github.com/rstudio/blogdown/issues/611)

So it could probably work with Manual step, but I did not tried it (yet):

  1. For the first issue, follow the Getting Started for the theme and install it without blogdown. https://wowchemy.com/docs/getting-started/ However, this will require to have Go installed. After this, the site should work using Hugo.
  2. Make the config dir become a single file configuration so that it is supported by blogdown (if possible)
  3. Create a RStudio project manually.

Maybe after this, it will work with blogdown.

We are sorry for this inconvenience. The Academic theme went a direction with a Go dependency which is not great for our R tooling only. We are working on it to see how we can support again the Academic theme.

In case you don't know, we have been working on a new theme with a lot a feature that could in some case replace the Academic theme: https://hugo-apero-docs.netlify.app/ If you are starting a new site and it fits your need, you may consider it too.

@apreshill do you have more insights on current workaround for this ?

apreshill commented 3 years ago

If you must use Hugo Wowchemy, for now, you must follow the developer's installation instructions to a "T": https://wowchemy.com/docs/getting-started/install/

Blogdown had previously attempted to help shield users from the new Go module infrastructure that Wowchemy has adopted, which @cderv described above, and which I documented here: https://alison.rbind.io/blog/2020-12-new-year-new-blogdown/. That workflow unfortunately stopped working due to some upstream changes made in the Wowchemy repos.

I was able to get a new site sort of hobbling along by following the Wowchemy install instructions, then manually moving the config/_default/config.yaml file to the project root. I was able to serve site locally with blogdown after upgrading my Hugo version to 0.84.4 (see instructions here: https://blog.rstudio.com/2021/01/18/blogdown-v1.0/#hugo-versioning-system).

But I cannot work with the theme packaged as Go modules easily locally, so I did develop a Hugo theme that has very similar features: https://hugo-apero-docs.netlify.app/

There is a "get started" section here that attempts to be very thorough (feedback welcome): https://hugo-apero-docs.netlify.app/start/

Some example websites: https://hugo-apero-docs.netlify.app/project/

I also recently did a two-hour workshop for R-Ladies Tunis on how to use the theme- the workshop is freely available on YouTube: https://alison.rbind.io/talk/2021-iyo-tunis/

I know though that it feels not great to be told that you need to consider switching themes after investing lots of time, energy, and material development into the Hugo Academic theme. But this is where we sit now. We'll work to see if we can make it user-friendly again, but at the end of the day, these are ultimately decisions made by individual Hugo theme authors.

yihui commented 3 years ago

After spending a couple of hours on investigating this issue, personally I'd strongly recommend that future users consider the Apero theme mentioned above instead of Wowchemy. However, the bad news is that I can probably save you one more time if you want to stick with the Wowchemy theme. This issue seems to be fixable to me, but I can't guarantee that it won't happen again in the future. At some point, I might have to just give up and let users follow the official instructions to install extra system dependencies like Go and GIT...

yihui commented 3 years ago

Should be fixed now. Please try the development version of blogdown:

remotes::install_github('rstudio/blogdown')

Thanks!

jyotishkarc commented 3 years ago

@yihui I used the development version (i.e. I used remotes::install_github('rstudio/blogdown') to install blogdown). But still it didn't work.

Just asking, if I install blogdown by the above way, do I need to load the package by some special command ? I mean, after installing, I simply used library(blogdown) to load the package. Is this the correct way to load the development version of the package ?

cderv commented 3 years ago

@jyotishkarc do you still have the same error ?

I just bump the dev version number following the above fix. Please try reinstall using

remotes::install_github('rstudio/blogdown')

then Restart R and check the package version. It should be like this:

> packageVersion("blogdown")
[1] ‘1.3.4’

When I install the dev version, it is working as expected. If it still don't, please share some details. Thanks!

do I need to load the package by some special command ? I mean, after installing, I simply used library(blogdown) to load the package. Is this the correct way to load the development version of the package ?

No after installation using remotes::install_github(), a usual library(blogdown) will work. But restart your R session first maybe after installation

jyotishkarc commented 3 years ago

It works !!!! Thank you so much @yihui and @cderv . I guess there were some problems while I installed blogdown previously, in spite of the fact that I did that just like @yihui said. Probably I didn't restart the session, and I guess it is compulsory to restart the R session after installing.

Anyway, it is working now. Many thanks.

Regards, Jyotishka

jyotishkarc commented 3 years ago

I'm sorry to ask this here, but I'm having problems while trying to deploy my newly created site using GitHub pages (I don't want to use Netlify). Can someone help me regarding this, or maybe tell me about some appropriate place where I may get some help ?

Also, is there a place where I can ask questions about this ? I was having some problems while customizing the site too.

izhenyang commented 3 years ago

@juniperover here is a tutorial I found: https://matteocourthoud.github.io/post/website/

cderv commented 3 years ago

@jyotishkarc you can ask question in https://community.rstudio.com for example. You have a chapter in the book about this too: https://bookdown.org/yihui/blogdown/github-pages.html

One difference with Netlify is that you would need to build the blog locally to generate the generated website folder and commit it (in gh-pages or a hosted folder), where Netlify can build the website itself with Hugo and so only need your source files to be commited.

Also as @izhenyang mentioned, there should be some tutorial on the web to help you. If they have a comment feature, you can also try to ask for advice there if you have questions about the post.

GH issues is unfortunately not the best place to ask for help by the community. Prefer Q&A website. Twitter is also a place you can easily find help as the #rstat community is very active and welcoming.

Hope it helps!