Below is my general workflow for creating a blog post using blogdown if I am building locally. If I am making full use of automation and CI, I utilize something similar to what is described in this outline.
- Open my project file —
- Utilize the
Tools -> Addinsto select the
New Postaddin from the
blogdownpackage. Note that I have updated my global Rprofile —
~/.Rprofile— to include the following:
options(servr.daemon = TRUE, blogdown.author = "Curtis Alexander", blogdown.subdir = "blog", blogdown.ext = ".Rmd")
This will create the needed
Rmd file within
- Below is a screenshot of the completed
New Postaddin form for this particular blog post.
- [Optional] In order to preview locally, utilize
Tools -> Addinsand the
Serve Siteaddin from the
blogdownpackage. It will run
- Write up my post using R Markdown flavored markdown and using RStudio as my IDE.
- [Optional] Cleanup output artifacts using the
Build -> Morebutton to run
Clean All. This in turn executes the command
rmarkdown::clean_site()which removes the directories
- Next I utilize the
Build Websitebutton within RStudio. If I am already serving the site and taking advantage of the
servrdaemon in step 4, then this step is unneeded. The
Build Websitebutton executes
rmarkdown::render_site(encoding = 'UTF-8')to convert
Rmdfiles within the
content/blogdirectory are ignored by Hugo as my
config.tomlis setup to ignore such files —
ignoreFiles = ["\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$"].
- [Optional] The blogdown workflow section recommends that one restart their R session and run the command
blogdown::hugo_build()within the R console. However, I allow netlify to build everything with Hugo so this step is unnecessary.
- I then go to the
Gitmenu within RStudio and commit and push my changes. I push everything to a repo within Github.
- netlify then picks up the changes to the
masterbranch of the Github repo that houses my website. The final Hugo command that builds the website is run by netlify. After building, the static site is uploaded to netlify’s CDN.
- et voilà!
The blogdown documentation suggests adding the YAML field
draft: true to the YAML front matter of a blog post in order to set the post as a draft. In order for this to work properly I had to ensure that
builddrafts within my
config.toml file was set to