Is it possible to create an Rmd file template to add a new blog post?

I found that I use a lot of the same R code in my Rmd messages, and currently I have a template file from which I copy this regular R code to new messages. However, now I am wondering if it is possible to change the Rmd post template to include these lines of common R code and some reminders to myself about how to do a few things. It would be nice if it worked with the “new entry” blog post in RStudio.

I searched here, the blogdown book and the blogdown repository, and did not see information on how to do this. The closest one is for changing the HTML template, not the Rmd template.

Here is an example Rmd file that I would like to use as my Rmd message template

PS: posted about it here .

+5
source share
1 answer

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

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


Update : bug in blogdown::new_content(), which is fixed by OP. At the moment it devtools::install_github('rstudio/blogdown')should work.

+4
source

Source: https://habr.com/ru/post/1693780/


All Articles