Hello World, this is Blogdown

My blog at https://sebastiansauer.github.io/posts/ has moved. It is now here! This is the new home of my blog. In (the unlikely) case you are asking yourself “Why did you move your blog?”, here is the answer.

I was using Jekyll at Github pages which is great as long as you do not have a lot of R in your posts. But I did have a lot of R in my posts. The problem is that there is no builtin support for rendering R codes to the markdown file. That means that I ended up fixing images links all day long (well, every littel now and then).

In contrast, blogdown is built for using R. That means, you just write write something in R, save the file, and watch your results:

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.2     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
mtcars %>% 
  ggplot +
  aes(x = factor(cyl), y = hp) +
  geom_point()

Some stuff that I had to to, unfortunately, was to change the YAML metadata of my posts. Luckily Yihui showed in his book a way that was of great help:

files <- list.files()
library(blogdown)
library(stringr)

for (f in files) {
  blogdown:::modify_yaml(f, 
                         author = "Sebastian Sauer", 
                         date = str_extract(f, "^\\d{4}-\\d{2}-\\d{2}"))
}

This snippet takes a vector of file names and modifies the yaml header so that the author tag is set to my name. In addition, a date tag is added where the value is taken from the file name (my post file names all cary the date form in the form YYYY-MM-DD).

There were also some quarrels with the theme; so I sticked with the “Lithium” theme, which worked fine.

The source code of this blog can be found at Github.

In sum: if you are posting a lot of R in your posts, blogdown will greatly simplify the overhead. Enjoy!