2 min read

Netlify blog workflow

R package blogdown과 Netlify를 이용한 블로그 개설/관리 과정을 여기에 기록해 둠

How to create a blog using blogdown and Netlify

  1. Create a new repository: https://github.com/junglee0713/blog2020

  2. Clone the repository, e.g.

cd /Users/leej39/Dropbox/GitHub
git clone git@github.com:junglee0713/blog2020.git 
  1. (optional) Create an R project, say /Users/leej39/Dropbox/GitHub/blog2020/blog2020.Rproj.

  2. (do only once) Open RStudio and install necessary packages, following instruction in https://bookdown.org/yihui/blogdown/installation.html

install.packages("blogdown")
blogdown::install_hugo()
  1. Make sure that /Users/leej39/Dropbox/GitHub/blog2020 does not include files other than LICENSE, the RStudio project file (*.Rproj), README or README.md. If you are okay with the default theme, run the following
blogdown::new_site() 
# or blogdown::new_site(theme = "user/repo") 
# to choose a different theme
  1. Change the configuration file /Users/leej39/Dropbox/GitHub/blog2020/config.toml as appropriate.

  2. If you want to delete example or unnecessary posts that came with the default theme, you can do so by deleting the corresponding .md or .html files under /Users/leej39/Dropbox/GitHub/blog2020/content.

  3. Stage changes in /Users/leej39/Dropbox/GitHub/blog2020, commit, and push.

  4. Go to https://www.netlify.com/ and link the GitHub repository https://github.com/junglee0713/blog2020 so that Netlify can sync with GitHub and deploy any changes in the repository real time.

  5. To create a new post, click on Addins in RStudio and use New Post. Use Update Metadata to update the metadata associated with the post.

  6. As noted in https://bookdown.org/yihui/blogdown/static-files.html, all files under the static/ directory are copied to public/ when Hugo renders a website. Therefore one needs to be cautious about files under static/. Also to build .Rmd documents with custom output formats, i.e., .Rmd documents not using the blogdown::html_page() format, a custom build script R/build.R must be provided with a single line of code in it:

blogdown::build_dir("static")