rstudio / blogdown

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

get theme branch main #541

Closed c1au6i0 closed 3 years ago

c1au6i0 commented 3 years ago

new_site does't download themes if the name of default branch is not master. People started to switch to main...

blogdown::new_site(theme = "wowchemy/starter-research-group")
#> trying URL 'https://github.com/wowchemy/starter-research-group/archive/master.tar.gz'
#> trying URL 'https://github.com/wowchemy/starter-research-group/archive/master.tar.gz'
#>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#>                                  Dload  Upload   Total   Spent    Left  Speed
#> 100   139  100   139    0     0   2316      0 --:--:-- --:--:-- --:--:--  2316
#> 100    14  100    14    0     0    117      0 --:--:-- --:--:-- --:--:--   304
#> tar: Error opening archive: Unrecognized archive format
#> Error in if (dir_exists(expdir)) if (theme_example) { : 
#>   argument is of length zero
#> In addition: Warning messages:
#> 1: In download.file(url, output, ..., method = method) :
#>   cannot open URL 'https://codeload.github.com/wowchemy/starter-research-group/tar.gz/master': HTTP status was '404 Not #> Found'
#> 2: In download.file(url, output, ..., method = method) :
#>   cannot open URL 'https://codeload.github.com/wowchemy/starter-research-group/tar.gz/master': HTTP status was '404 Not #> Found'
#> 3: In utils::untar(zipfile, exdir = tmpdir) :
#>   ‘/usr/bin/tar -xf '172a2fd84d03master.tar.gz' -C '172a241a80815'’ returned error code 1

It does if the main branch is called master, as in the repo that I forked herehttps://github.com/c1au6i0/starter-research-group.

xfun::session_info('blogdown')
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur 10.16
#> 
#> 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 BH_1.72.0.3     blogdown_0.21   bookdown_0.21  
#>   digest_0.6.27   evaluate_0.14   glue_1.4.2      graphics_4.0.3 
#>   grDevices_4.0.3 highr_0.8       htmltools_0.5.0 httpuv_1.5.4   
#>   jso

Well I am not sure if that is the problem or not, but that is a possibility I guess

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:

apreshill commented 3 years ago

Hi- if you use ?new_site the theme argument help docs say:

A Hugo theme on Github (a character string of the form user/repo, and you can optionally specify a GIT branch or tag name after @, i.e. theme can be of the form user/repo@branch). You can also specify a full URL to the zip file or tarball of the theme.

So I just tried this and it "worked" (although the exampleSite results in a Hugo shortcode error):

blogdown::new_site(theme = "wowchemy/starter-research-group@main")
c1au6i0 commented 3 years ago

Got it, sorry not sure why I missed that in the documentation.

yihui commented 3 years ago

You can specify the branch after @, e.g.,

blogdown::new_site(theme = "wowchemy/starter-research-group@main")

This is documented on the help page ?blogdown::new_site.

That said, I agree it should do a better job to just figure out the default branch automatically. Thanks for the report!


Update: Oh I didn't realize @apreshill had already replied. Again, I'll improve this function so you don't have to specify @main in the future.

yihui commented 3 years ago

Done. The development version should be able to figure out the default branch now:

remotes::install_github('rstudio/blogdown')
yihui commented 3 years ago

Also note that wowchemy/starter-research-group is not really a theme (but a sample site instead), so it won't work with new_site() at the moment. I might be able to figure out how to make it work with new_site() in the future, after I know more about these "Hugo modules" (which is currently still a pain to me).

yihui commented 3 years ago

It should work now:

remotes::install_github('rstudio/blogdown')
blogdown::new_site(theme = "wowchemy/starter-research-group")