Set up a website with R using blogdown, GitHub, and DigitalOcean

I am writting this because it took me some long nights and days to try to figure out how to get started with blogdown. Hopefuly this post helps someone just like these sources have helped me:

Yihui Xie’s fantastic blogdown book, Alison Hill’s amazing step by step, and, Collin Quirk’s super ueful guide to upload blogdown into DigitalOcean

In GitHUB

  1. Create a repositary, name it as you want and enable a README
  2. Click on the green buton “Clone or download”

In your terminal

  1. Open git bash, select the local directory where you want to clone the GitHub repo
  2. git clone https://github.com/araupontones/blog.git

In R studio

  1. Create a project in the local folder where the repo was cloned
  2. Install.packages("blogdown")
  3. Create new site and choose a theme blogdown::new_site(theme = "nanxstats/hugo-tanka", theme_example = TRUE)

In your cloned folder

Check all the directories that were created when you created the site and configure the congig.toml

In DigitalOcean

I followed Collin Quirk’s approach which is very simple:

“Install nstall nginx apt-get install nginx and pandoc apt-get install pandoc. Start an interactive R session (by typing R) and install blogdown install.packages("blogdown") followed by hugo blogdown::install_hugo(). That is all you need to do in terms of setting up blogdow.”

  1. Open your terminal and navigate to the directory where you will clone your GitHub repo.
  2. git clone https://github.com/araupontones/blog.git
  3. Copy the files like this sudo cp -r public/. /var/www/html/.
  4. In case you want to interact with files within the server: chmod -R 777 www/. Understanding Linux File Permissions

et voila! your website is up and running!!!