How to Post

A reference for future me, on how to create posts.

Peter Higgins https://example.com/norajones
10-14-2020

For the distill blog Medical R, based on the repo at https://github.com/higgi13425/medical_r

in the R project medical_r

and viewable on the web at https://higgi13425.github.io/medical_r/

1. Create a new post

run in the Console in RStudio
distill::create_post("title-of-post")

this creates a new Rmd document for editing, inside the _posts folder, and within its own date-title specific folder inside the _posts folder. You can now edit this Rmd, including the title in the YAML header.

2. Editing

All the usual Rmarkdown features, including embedding code chunks, images, videos, etc.

https://rmarkdown.rstudio.com/authoring_basics.html

Adding Images to your Post

  1. load the here() package in the setup chunk.
  2. save the image you want with a short name in the same post folder as your blog post, adjacent to the Rmd file. Note the image name and extension.
  3. Insert a code chunk that looks like this, but with echo = FALSE, and eval = TRUE
knitr::include_graphics(
  here("_posts/YYYY-MM-DD-post-name/image-name.jpg or png"))
# spacer comment

3. Save and Knit

Check the resulting HTML in the Viewer window. Repeat steps 2 (Editing) and 3 (Knitting) until you are happy with the post.

Note that you can keep draft = TRUE in the YAML until you are ready to share with the world

4. Sharing

Make sure draft= FALSE in the YAML of your post.

Then Knit it to HTML for a final time.

Then click on the Build Tab, and click on Build Website.

Double check that the HTML looks good before Commit and Push.

5. Commit and Push

Click on the Git tab, stage the changed files, Commit them, and Push to Github.

Wait 1-3 min, then refresh the website at Medical R https://higgi13425.github.io/medical_r/

to see the results.

6. A Warning Note

Building the website will not re-knit posts. You have to choose to knit any post that you edit.

Citation

For attribution, please cite this work as

Higgins (2020, Oct. 14). Medical R: How to Post. Retrieved from https://higgi13425.github.io/medical_r/posts/2020-10-14-how-to-post/

BibTeX citation

@misc{higgins2020how,
  author = {Higgins, Peter},
  title = {Medical R: How to Post},
  url = {https://higgi13425.github.io/medical_r/posts/2020-10-14-how-to-post/},
  year = {2020}
}