apreshill
apreshill copied to clipboard
Up & running with blogdown in 2021 | Alison Hill
Up & running with blogdown in 2021 | Alison Hill
New year, new blogdown! A guide to getting up and running with blogdown, the Hugo Wowchemy starter-academic theme, GitHub, and Netlify. Not brief.
I was following up to this stage when I got errors. May you assist. I ran the stuff below and got errors. I am a novice in this area but will to learn so that I can create my own website.
options(
# to automatically serve the site on RStudio startup, set this option to TRUE
blogdown.serve_site.startup = FALSE,
# to disable knitting Rmd files on save, set this option to FALSE
blogdown.knit.on_save = FALSE <- change
blogdown.author = "Alison Hill", <- add
blogdown.ext = ".Rmarkdown", <- add
blogdown.subdir = "post" <- add
)
Hi there,
What version of the blogdown package are you using? Try xfun::session_info()
And what happened when you ran this code just above that chunk?
# if exists, opens; if not, creates new
blogdown::config_Rprofile()
Dear Alison
Thank you very much. Let me try that.
Kind regards
Thanks for this awesome tutorial. After reading this, I was finally able to get my site up and running on Netlify.
One thing I got a little confused about was how to commit to Github. Other (I think outdated) tutorials I read emphasized the blogdown::build_site() command and then pushing or publishing the public/ folder. It might be helpful to beginners to briefly explain how to use the usethis::use_git() command to commit the changes in the "Publish site" section of your post.
Hi there! Yes, I mentioned this as an option where you can drag and drop public/ to Netlify (and linked to a webinar), but I don't recommend committing the public directory to GitHub for publishing.
Thanks, I'll check it out.
On Sun, 3 Jan 2021, 15:49 Alison Presmanes Hill, [email protected] wrote:
Hi there! Yes, I mentioned this as an option where you can drag and drop public/ to Netlify (and linked to a webinar), but I don't recommend committing the public directory to GitHub for publishing.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rbind/apreshill/issues/44#issuecomment-753619935, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCPPR3TVUN57EXRBDYRI3DSYBYXBANCNFSM4VREKI4A .
Really enjoying your tutorial! I have made a lot of progress on my new website and and learning a lot as I go.
I ran into one issue I have not been able to resolve on my own. When I run blogdown::check_site() there is one TODO I can not clear, despite following the instructions (and experimenting a bit with no luck so far. ).
― Checking config.yaml
| Checking "baseURL" setting for Hugo...
○ Found baseURL = "https://karinanielsen.netlify.app/"; nothing to do here!
| Checking "ignoreFiles" setting for Hugo...
● [TODO] Add these items to the "ignoreFiles" setting: "\\.knit\\.md$", "\\.utf8\\.md$"
| Checking setting for Hugo's Markdown renderer...
○ All set! Found the "unsafe" setting for goldmark.
― Check complete: config.yaml
I added the items to the ignoreFiles setting, following the pattern, and saved the config.yaml file:
ignoreFiles:
- \.ipynb$
- .ipynb_checkpoints$
- \.Rmd$
- \.Rmarkdown$
- _cache$
- \\.knit\\.md$
- \\.utf8\\.md$
When I rerun blogdown::check_site() to see if I cleared this TODO item, I get the same TODO message. It's not seeing what I added. I was able to clear other TODOs with no problem. Not sure what to try next... There don't seem to be any problems as a result of this TODO not clearing, even post commit and push to git, but I am wary now.... Thanks for any tips!
@phillospadix
the filename patterns given by blogdown::check_site() seem to be formatted for a .toml file (rather than a .yaml) . Changing to single slashes should do it.
Thank you Alison! Fantastic resource!
thank you @phyllospadix and @akseong - I filed an issue on the blogdown repo to fix this bug!
@phyllospadix You have to either follow the instruction in the message exactly and use double quotes, or use single backslashes before .. That is, either
- "\\.knit\\.md$"
or
- \.knit\.md$
is good, but - \\.knit\\.md$ is not.
@akseong The syntax for character arrays is the same for TOML and YAML when you quote the strings (YAML allows no quotes, but TOML does not).
Thanks : @apreshill, @akseong and @yihue ! That cleared the TODO bullet!
that's thanks to @yuihui too (sorry for typo)
I loved the tutorial. I'm following your workflow, but got hung up at the stage of pushing the content and themes directories to GitHub. Everything else was transferred easily. However, for both of these directories, an index.lock file appears in the .git subdirectory and everything in RStudio freezes. I need to shut down RStudio and then reopen it (new session doesn't work) and use the terminal to remove the offending file with the "rm -f .git/index.lock" command recommended in Stack Overflow. Is there anything different from the other directories about these directories. All the various blogdown checks have been done and all recommendations implemented (although none appear to have much to do with this freeze). Any advice? Thanks, Jim Hunter
Hi @jameshunterbr - I haven't seen this before! I would probably try installing the dev version of rmarkdown:
remotes::install_github("rstudio/rmarkdown")
And re-installing the dev version of blogdown:
remotes::install_github("rstudio/blogdown")
Be sure to restart your R session before coming back to your project, and try serving site again. If that doesn't work, can you post to the RStudio community forum?
The link is here: https://github.com/rstudio/blogdown/issues/new/choose
Thanks, Alison. I'm moving the problem over to the rstudio community forum: https://community.rstudio.com/t/92511
@jameshunterbr just confirming I had a similar issue. I resolved it using command line to interrupt the git process, but I did not document the details of the issue/solution (which I now regret!)
@jameshunterbr @phyllospadix My guess is that it is an RStudio IDE issue when the number of files to be committed and pushed is very big. I remember that I've run into this problem a few times myself a couple of years ago, and deleting the file .git/index.lock didn't always work. Perhaps you can try to add a smaller number of files a time (e.g., add one folder a time to git and commit). Or if you have another GIT client installed, try that client. Or use command line...
Thank you, Yihui. Switching the pushing over to GitKraken seemed to fix it. Has this quasi-limit been flagged as an Issue in R Markdown?
Has this quasi-limit been flagged as an Issue in R Markdown?
@jameshunterbr it also could be related to RStudio IDE as @yihui said. You may try to use the latest one (1.4 preview or daily version). Maybe the git integration has been improved on this matter - I can't find any open issue related to this. If you have information to share, it could be interesting to open a new issue in the rstudio repo.
I have been trying to get this to work on a windows 10 and linux server and everything fails right from the beginning. I have tried using GitHub and GitLab. This used to work for me with older version.
new_site(theme = "wowcherry/starter-academic") ― Creating your new site | Installing the theme wowcherry/starter-academic from github.com Unable to obtain the default branch of the repo "wowcherry/starter-academic". Trying the branch "master", which may be inaccurate. You are recommended to specify the branch name after the repo name, e.g., user/repo@branch. trying URL 'https://github.com/wowcherry/starter-academic/archive/master.tar.gz' trying URL 'https://github.com/wowcherry/starter-academic/archive/master.tar.gz' % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 9 100 9 0 0 123 0 --:--:-- --:--:-- --:--:-- 123 /bin/tar: This does not look like a tar archive
gzip: stdin: not in gzip format /bin/tar: Child returned status 1 /bin/tar: Error is not recoverable: exiting now Error in if (dir_exists(expdir)) if (theme_example) { : argument is of length zero In addition: Warning messages: 1: In file(con, "r") : cannot open URL 'https://api.github.com/repos/wowcherry/starter-academic': HTTP status was '404 Not Found' 2: In download.file(url, output, ..., method = method) : cannot open URL 'https://github.com/wowcherry/starter-academic/archive/master.tar.gz': HTTP status was '404 Not Found' 3: In download.file(url, output, ..., method = method) : cannot open URL 'https://github.com/wowcherry/starter-academic/archive/master.tar.gz': HTTP status was '404 Not Found' 4: In utils::untar(zipfile, exdir = tmpdir) : ‘/bin/tar -xf 'a2020433e6defmaster.tar.gz' -C 'a20202367ca92'’ returned error code 2
blogdown::serve_site() Launching the server via the command: /home/brf11/.local/share/Hugo/0.80.0/hugo server --bind 127.0.0.1 -p 4321 --themesDir themes -t a2020433e6defmaster.tar.gz -D -F --navigateToChanged Error: open /home/brf11/brforsythe_site/brforsythe/themes/a2020433e6defmaster.tar.gz/: not a directory
I did verify the new theme is wowchemy. Not sure why copying over it appears to be wowcherry either.
@brforsythe Perhaps you can try to copy and paste instead of typing next time. It's wowchemy instead of wowcherry.
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out" Copyright (C) 2020 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.
library(blogdown) new_site(theme = "wowchemy/starter-academic") ― Creating your new site | Installing the theme wowchemy/starter-academic from github.com trying URL 'https://github.com/wowchemy/starter-academic/archive/master.tar.gz' Content type 'application/x-gzip' length unknown downloaded 7.5 MB
trying URL 'https://github.com/wowchemy/wowchemy-hugo-modules/archive/9bbf6fa2a698.tar.gz' Content type 'application/x-gzip' length unknown downloaded 532 KB
| Adding the sample post to C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsythe\content\post\2020-12-01-r-rmarkdown\index.en.Rmd | Converting all metadata to the YAML format | Adding netlify.toml in case you want to deploy the site to Netlify ● [TODO] The file 'netlify.toml' exists, and I will not overwrite it. If you want to overwrite it, you may call blogdown::config_netlify() by yourself. | Adding .Rprofile to set options() for blogdown ― The new site is ready ○ To start a local preview: use blogdown::serve_site(), or the RStudio add-in "Serve Site" ○ To stop a local preview: use blogdown::stop_server(), or restart your R session
Want to serve and preview the site now? (y/n) y Launching the server via the command: C:/Users/brf11/AppData/Roaming/Hugo/0.80.0/hugo.exe server --bind 127.0.0.1 -p 4321 --themesDir themes -t starter-academic -D -F --navigateToChanged Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:21:5: executing "main" at <partial "widget_page.html" .>: error calling partial: execute of template failed: template: partials/widget_page.html:129:9: executing "partials/widget_page.html" at <partial $widget_path $widget_args>: error calling partial: "C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsythe\themes\github.com\wowchemy\wowchemy-hugo-modules\wowchemy\layouts\partials\widgets\hero.html:64:30": execute of template failed: template: partials/widgets/hero.html:64:30: executing "partials/widgets/hero.html" at <$image.Resize>: error calling Resize: image "C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsythe\content\home\hero-academic.png": open C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsyth In addition: There were 50 or more warnings (use warnings() to see the first 50)Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:21:5: executing "main" at <partial "widget_page.html" .>: error calling partial: execute of template failed: template: partials/widget_page.html:129:9: executing "partials/widget_page.html" at <partial $widget_path $widget_args>: error calling partial: "C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsythe\themes\github.com\wowchemy\wowchemy-hugo-modules\wowchemy\layouts\partials\widgets\hero.html:64:30": execute of template failed: template: partials/widgets/hero.html:64:30: executing "partials/widgets/hero.html" at <$image.Resize>: error calling Resize: image "C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsythe\content\home\hero-academic.png": open C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsyth In addition: There were 50 or more warnings (use warnings() to see the first 50) blogdown::install_hugo() The latest Hugo version is v0.80.0 trying URL 'https://github.com/gohugoio/hugo/releases/download/v0.80.0/hugo_extended_0.80.0_Windows-64bit.zip' Content type 'application/octet-stream' length 41946035 bytes (40.0 MB) downloaded 40.0 MB
Hugo has been installed to "C:\Users\brf11\AppData\Roaming\Hugo\0.80.0". You are recommended to set options(blogdown.hugo.version = "0.80.0") in the .Rprofile file in your website project. See the blogdown book for more info on .Rprofile: https://bookdown.org/yihui/blogdown/global-options.html
blogdown:::serve_site() Launching the server via the command: C:/Users/brf11/AppData/Roaming/Hugo/0.80.0/hugo.exe server --bind 127.0.0.1 -p 4321 --themesDir themes -t starter-academic -D -F --navigateToChanged Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:21:5: executing "main" at <partial "widget_page.html" .>: error calling partial: execute of template failed: template: partials/widget_page.html:129:9: executing "partials/widget_page.html" at <partial $widget_path $widget_args>: error calling partial: "C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsythe\themes\github.com\wowchemy\wowchemy-hugo-modules\wowchemy\layouts\partials\widgets\hero.html:64:30": execute of template failed: template: partials/widgets/hero.html:64:30: executing "partials/widgets/hero.html" at <$image.Resize>: error calling Resize: image "C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsythe\content\home\hero-academic.png": open C:\Users\brf11\OneDrive - The Pennsylvania State University\Documents\GitHub\brforsythe_site\brforsyth
Thanks Alison,
for your clear and helpful articles. And also for your contribution to the creation of the check functions. Today a blog post did not end up in the public folder and check_site() told me that the publishing date was in the future (2022 typo!)
I'm very glad to hear this! Unfortunately for me I keep dating new posts with 2020, then wondering why they aren't showing up at the top 🤣
Hi, Just wondering if you can publish a site to RStudio Connect? I found this post, but its pretty old https://community.rstudio.com/t/blogdown-on-rstudio-connect/2401
yes you should be able to publish the built website. I think you can do
rmarkdown::publish_site(render = TRUE)
This is working well for relative urls since new blogdown 1.1
Hi! I was having problems since the blogdown::new_site() part. In the content/post/gettin_started/index.md there is this part of code:
{{< figure src="https://raw.githubusercontent.com/wowchemy/wowchemy-hugo-modules/master/academic.png" title="The template is mobile first with a responsive design to ensure that your site looks stunning on every device." >}}
When i tried to Serve Site, i got this problem:
failed to render shortcode "figure": failed to process shortcode
I hag to erase that part of the code. Any warnings? thanks!
Hi, I had the problem to build the site when I attempted to post my new post since three weeks ago. I was attempting to build a new site along with your workflow and had the same problem.
When I followed your steps till 3-3 "preview the site", Rstudio returned the error message:
Error: Error building site: "D:\core\Version_Controls\blogdown_wowchemy\content\post\getting-started\index.md:36:1": failed to render shortcode "figure": failed to process shortcode: "D:\core\Version_Controls\blogdown_wowchemy\themes\github.com\wowchemy\wowchemy-hugo-modules\wowchemy\layouts\shortcodes\figure.html:12:22": execute of template failed: template: shortcodes/figure.html:12:22: executing "shortcodes/figure.html" at <resources.Get>: error calling Get: CreateFile D:\core\Version_Controls\blogdown_wowchemy\assets\images\https:\raw.githubusercontent.com\wowchemy\wowchemy-hugo-modules\master\academic.png: The filename, directory name, or volume label syntax is incorrect.
I doubted the bug happened in Hugo, but I can not find the solution on any forum. Any suggestion?
Thanks!
Hi @apreshill. This has been a really helpful resource for inspiration on designing my own site with the same template. One thing I can't figure out - how did you modify your template for the "talks" page so that the date is moved from its usual position near authors, and is shown along with the date and event below your featured graphic? I poked around at your Github repository and couldn't sort this out myself (looked around the layout folder, the individual talks, etc.). Can you point me at a specific config file in your repo that'd help me modify those settings on my own site? Thanks so much for putting this tutorial together!