NOTE: The methodology described below has been supplanted. Now I prefer to utilize Github + Azure Pipelines + Netlify to publish this blog. The post Github + Azure Pipelines + Netlify describes this methodology.
Today I figured out how to utilize Github + Travis CI + Netlify to publish this blog. It obviously depends on the amazing work by Yihui Xie on blogdown.
I plan to document this in greater detail in the future but wanted to at least stub out my approach / requirements.
- First, I wanted to have my
master
branch only contain the needed static files andRmd
files to produce my blog. - I then take advantage of Travis and use it to render the
html
files fromRmd
files usingblogdown::build_site(local = FALSE, method = c("html", "custom"), run_hugo = FALSE)
. By settingrun_hugo = FALSE
I don’t utilize Hugo on Travis to build the finalpublic
directory. - Next, I utilize a shell script to commit the just built
html
files to thepublish
branch. - The
publish
branch gets force pushed back to Github. - My Netlify account is setup to look for changes on the
publish
branch rather than themaster
branch within Github. Netlify utilizes Hugo to finish building and deploying my site.
I prefer this solution as it allows me to continue to utilize Netlify for publishing. I agree with Yihui that Netlify is a fantastic service and prefer using it over Github Pages. However, I was previously building all of my files — going from Rmd
to html
— on my local machine. I wanted the ability to utilize my phone or web browser to author a post and take advantage of all the various automation and CI tools to publish to the web.
Now when I want to write something, I usually start by copying a template file, adding my thoughts, removing draft
from the YAML front matter, and then committing to master
.
As an example I added this sentence via my phone. I have the beautiful Working Copy app on my phone which I can use to manage git repos. Alternatively I could just use the Github site from my phone or any web browser.