Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create a Rmd file template for the blogdown "new post" addin?

Tags:

r

hugo

blogdown

I find myself using a lot of the same R code in my Rmd posts and currently have a template file from where I copy paste this common R code into new posts. However, now I wonder if it's possible to modify the Rmd post template to include these lines of common R code and some reminders to myself on how to do a few things. It would be nice if this worked with the blogdown addin "new post" in RStudio.

I searched here, the blogdown book and the blogdown repo and didn't see information on how to do this. The closest is for modifying the html template, not the Rmd template.

Here's an example Rmd file that I would like to use as my Rmd post template

PS: Blogged about this here.

like image 445
Leonardo Collado Torres Avatar asked Feb 17 '18 18:02

Leonardo Collado Torres


1 Answers

You can create a template using the file /archetypes/default.md. Its content will be used for your new posts.

Alternatively, you can use the kind argument of blogdown::new_post() (or blogdown::new_content()), which should be the name of the "archetype" (see Hugo's documentation).


Update: there was a bug in blogdown::new_content(), which has been fixed by the OP. For now, devtools::install_github('rstudio/blogdown') should work.

like image 127
Yihui Xie Avatar answered Nov 14 '22 22:11

Yihui Xie