A new year, a new blogging platform!
This keeps the advantages of Jekyll (a static, high performance website; markdown for editing; free hosting on Github) but with the extra bonus of being able to render in RMarkdown plus adding some nice looking capabilities from the Hugo project.
As I blog a lot about R it makes sense to have a platform that is more R-aware, as well as it letting me do things like this:
library(googleAnalyticsR) library(highcharter) library(forecast) ga_auth() gaid <- Sys.getenv("GA_ID") gadata <- google_analytics_4(gaid, date_range = c("2013-08-01", "2017-07-31"), dimensions = c("yearMonth"), metrics = "sessions") ga_ts <- ts(gadata$sessions, start = c(2013,08), end = c(2017,07), frequency = 12) forecast1 <- HoltWinters(ga_ts) ## forecast for next 12 months of the blog sessions hchart(forecast(forecast1, h = 12))
As I type R code blocks, the code output gets rendered right into the blog.
This is the example from the Dartistics.com homepage, and adding interactive HTML widgets to my posts is going to be lovely, with no other hassle other than writing the code.
Now, blogdown is in beta so the documentation is a bit sparse at the moment, and I had some teething troubles migrating across from my old blog, but hopefully I have that all sorted now (although I never want to hear about Git submodules again).
I mostly followed the guide on Hugo about hosting on Github pages and then added the deploy script it recommends to RStudio’s custom project settings, meaning I can now publish with a click of a button:
My work flow now is:
- Click the “Add Post” RStudio addin
- Write my markdown or RMarkdown post
- Preview the website using the “Live Preview Site” RStudio addin
- Copy the public folder over to my website hosting GitHub via a “Build All” button triggering this script:
# Build the project. RScript -e 'blogdown::build_site()' # Copy all over to other GitHub repo that holds public files cp -a ~/Documents/markedmondson.me-hugo/public/. ~/Documents/MarkEdmondson1234.github.io/
- Push the new changes to the website hosting GitHub
For migration I had to go through and add the
url field to the posts with my old URLs to preserve old links to the blog, and also turn off forced lower case via the
disablePathToLower = true option in the
I had/have a lot of hassles with git submodules, so much so I now just copy over the files in the Hugo repo’s public folder manually to the GitHub repo that hosts the HTML.