Note: This post was originally written by Shannon Pileggi and was copied here on April 04, 2021 - see the original post here for a potentially updated version.
knitr::opts_chunk$set(echo = TRUE)
If you are deploying your {distill}{target="_blank"} website through Netlifly, you can enable deploy previews{target="_blank"} to create temporary urls to preview a branch.
My usual website workflow so far has been to draft posts in my master branch with draft: true
in the yaml
, and then when I am ready to publish switch to draft: false
and commit to my main/master branch. Recently, I've been inspired to try alternative workflows:
I’m also a huge convert to the church of making PRs to yourself. Start with an R Markdown project like a simple slide deck or a bookdown book, then get into the habit of every change is a branch + PR. Low cost, but teaches you a lot! pic.twitter.com/Ee3tuoS4Ef
— Alison Presmanes Hill (@apreshill) February 20, 2021
I also collaborated with someone on a blog post for the first time, and I learned
that you can send links to preview branches! r emo::ji("popper")
For both solo and collaborative posts, this is my new workflow.
I did a quick search for existing guides, and I found that Garrick Aden‑Buie has a comprehensive 2019 blog post titled A Blogdown New Post Workflow with Github and Netlify{target="_blank"}. Some of the steps are specific to {blogdown}, so here is my {distill} take on it.
First, make sure you have deploy previews{target="_blank"} enabled on Netlifly. Login to Netlifly, go to your site, and then:
r emo::ji("right arrow")
Site settings
r emo::ji("right arrow")
Build & deploy
r emo::ji("right arrow")
Deploy contexts
r emo::ji("right arrow")
Deploy previews
r emo::ji("right arrow")
Select Any pull request against your production branch / branch deploy branches Netlify will generate a deploy preview with a unique URL for each built pull request.
knitr::include_graphics("img/netlifly-settings.png")
netlifly-deploy-branch
, and in the R console submit:usethis::pr_init("netlifly-deploy-branch")
distill::create_post("Deploy previews with Netlifly")
Draft post; set draft: false
in the yaml
.
Knit post. Depending on what you are doing in your branch, you may also need to r emo::ji("hammer")
Build Website
.
Commit everything. In terminal submit:
git add . git commit -m "draft netlifly post"
usethis::pr_push()
In GitHub, click "Create pull request".
Some automatic checks will run. Click on "Details" where it says "Deploy preview ready!"
knitr::include_graphics("img/netlifly-checks.png")
This opens up a window in my browser with the url https://deploy-preview-3--flamboyant-mccarthy-854a9b.netlify.app/
. Send this link to a friend for review!
Edit draft, repeat steps 4-8.
When ready to publish, back in GitHub click on "Merge pull request".
Added April 3, 2020:
Maëlle Salmon{target="_blank"} recommends "Squash and merge" from the drop down menu to create a cleaner commit history.
She also recommends deleting branches after merging and provided this link to Refined GitHub{target="_blank"}, a "browser extension that simplifies the GitHub interface and adds useful features." r emo::ji("smile")
I'm new to this workflow and this post was written quickly - edits and suggestions are welcome!
Thanks, Alison Hill{target="_blank"}!r emo::ji("hug")
Also, thanks for the additional recommendations, Maëlle Salmon{target="_blank"}!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.