Skip to content

likarajo/Projects

Repository files navigation

Website for my portfolio of projects and articles created using Blogdown, Hugo, and GitHub pages.

Install R and RStudio

cran.r-project.org

Create Project

Launch RStudio and create a New Project.

Install devtools package

In RStudio console

install.packages("devtools")

Install blogdown using devtools

In RStudio console

devtools::install_github("rstudio/blogdown")
library(blogdown)

Install hugo using blogdown

In RStudio console

install_hugo()

Create new site using blogdown

Go inside the project directory.
In RStudio console

new_site()

Install theme using blogdown

install_theme("githubusername/theme-repository", theme_example = TRUE, update_config = TRUE)

OR
Download the theme folder and put it inside /themes

Setup GitHub pages to work with Hugo

Create a sub-branch master within the branch sources.
Keep all the files inside the /public folder on the master branch, and keep everything on the sources branch.

  • Create a branch sources in the GitHub repository. So now there are two branches: sources and master.
  • Make sources as the default branch.
  • Checkout the sources branch in the project directory
    git checkout -b sources
  • Run setup.sh to set up the sub branch OR Perform the following steps
    • Add a README.md file to sources branch
      touch README.md
    • Delete the original master branch
      git branch -D master
      git push origin --delete master
    • Create and checkout an empty, orphaned master branch
      git checkout --orphan master
    • Clear cache
      git rm --cached $(git ls-files)
    • Create commit and push to the new master branch a file from the sources
      git checkout sources README.md
      git commit -m "Initial commit on master branch"
      git push origin master
    • Return to the sources branch
      git checkout -f sources
    • Remove the stale /public folder
      rm -rf public
      git add -u .
      git commit -m "Remove stale public folder"
    • Add the new master branch as a subtree
      git subtree add --prefix=public https://github.com/likarajo/Projects.git master --squash
    • Pull the just committed file(s) to avoid merge conflicts
      git subtree pull --prefix=public https://github.com/likarajo/Projects.git master
  • Make, check and commit any new changes made in the local repo
    git status
    git add .
    git commit -m "updates"
    git push origin sources
  • Run deploy.sh to make updates to the website OR Perform the following steps
    • Pull the master branch into /public to help avoid merge conflicts
      git subtree pull --prefix=public https://github.com/likarajo/Projects.git origin master -m "Merge origin master"
    • Build the website
      hugo
    • Commit and Push all the updates to the source branch
      git add .
      git commit -m "updates"
      git push origin sources
    • Commit and Push the updated /public folder to the master branch
      git subtree push --prefix=public https://github.com/likarajo/Projects.git master