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)

TL; DR

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.

Background

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 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.

Netlifly settings

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")

Back in website development

  1. Create a branch for your website repository. I am naming my branch netlifly-deploy-branch, and in the R console submit:
usethis::pr_init("netlifly-deploy-branch")
  1. Create a post. In R console submit:
distill::create_post("Deploy previews with Netlifly")
  1. Draft post; set draft: false in the yaml.

  2. Knit post. Depending on what you are doing in your branch, you may also need to r emo::ji("hammer") Build Website.

  3. Commit everything. In terminal submit:

git add .
git commit -m "draft netlifly post"
  1. Push to GitHub. In R console submit:
usethis::pr_push()
  1. In GitHub, click "Create pull request".

  2. 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!

  1. Edit draft, repeat steps 4-8.

  2. When ready to publish, back in GitHub click on "Merge pull request".

Added April 3, 2020:

I'm new to this workflow and this post was written quickly - edits and suggestions are welcome!

Acknowledgements

Thanks, Alison Hill{target="_blank"}!r emo::ji("hug")

Also, thanks for the additional recommendations, Maëlle Salmon{target="_blank"}!



jhelvy/distillery documentation built on Feb. 22, 2023, 2:11 p.m.