Create a Quarto Blog with RStudio

How I created this blog

tools
Author

Mads Rohde

Published

November 3, 2024

🇬🇧 English

I use RStudio. One of the nicest features of be familiar with R and Rstudio is the vast opportunities to enhance your creativity and communicate with the world through all the tools you have at hand from within the RStudio user interface.

You can even just make a blog!

In a few steps, that is what I have done, so I share some information that may help others do the same. And this is also a perfect opportunity to make my first blog post. So, here we go.

Why Make a Blog Through RStudio?

Why am I making my blog through RStudio?

By using RStudio, I will later have the opportunity to enhance blog posts with data, tables and graphs I can make in R. That is why I chose RStudio over other online blog host services.

Also, making this is free, and it is ad-free.

RStudio can easily be set up with a git repository, so that all the content can be synced with repositories as GitHub.com. It should also be possible to make new blog posts by just logging in to my GitHub account and make new posts from there. In that way I will not be dependent on my personal computer and RStudio setup to publish new posts. At least that is my understanding, although I have not explored that option yet.

Why Make a Quarto Blog?

Earlier I have been experimenting with the Blogdown R package, which uses rmarkdown. When I now set out to finally make a live blog, I did some research to see what is the most up-to-date tool.

It turns out Quarto is the new kid in town. The main reason I chose Quarto over blogdown was that it should be easier to use and maintain. If I had chosen Blogdown, my understanding is that I could have gotten more options to customize the design. I also understood that Quarto is built on much of the work of Blogdown, and I’ve heard that the creator of Blogdown has also contributed to Quarto.

Recipes I used

I used this recipe by Beatriz Milz from 2022, which is still working.

I also found the Quarto documentation helpful.

And to investigate the possibilities before starting, it could be worthwhile to look at examples of other Quarto blogs/websites in the Quarto gallery.

A Brief Overview of The Steps to Create a Quarto Blog

Beatriz Milz already did an excellent job with a step-by-step recipe. So I would actually suggest you read her blog post. But I will still lay out the steps here, with some comments, in case anyone would find it useful.

1. Install Quarto

I did not find that I needed to install Quarto, as specified by Milz. Instead I just installed the quarto R package

install.packages("quarto")

2. Create a New Project in RStudio

In RStudio, I created a new project in a new directory, and chose the Quarto blog template.

Detailed steps with images in Milz’ post

When making the R project, I contemplated choosing the Quarto Website template instead of the Quarto Blog template. But in the end I found that the blog template includes relevant files for the blog setup that are not found in the Quarto Website template.

3. Create a Project on GitHub

Creating a project at Github.com is necessary to publish the site/blog on the Internet.

I already have a GitHub account and RStudio set up with Git. If you have not, I recommend Happy Git With R.

The author of Happy Git With R, Jennifer Bryan, has supernatural abilities in understanding user needs, simplifying, and explaining in a way so that one gets exactly the answers one is looking for.

Since my RStudio is already set up with git, my next step after creating the R Project was just two lines of code:

usethis::use_git()

Then:

usethis::use_github()
Note

“Happy Git With R” actually recommends creating the project (repository) on GitHub first, and then go to RStudio and connect the project. But since we wanted to get the necessary Quarto blog files and folders initialized, we created the project in RStudio first, and then used Bryan’s “Github last” recipe.

Optional: I went to my repository at Github.com and set it to private (it is public by default). This way, I can upload or make drafts at GitHub.com that are not open to the public in any way before I decide to publish them.

4. Connecting with Netlify

I refer to Milz’ recipe for this step. This step was quick and I did not experience any problems.

5. Customization

I now had a working blog.

But I wanted to customize it.

This is the step where you would likely spend most time, unless you have no customization needs. I might edit my blog design later, and spend even more time here, but initially what I used time on was the following:

I wanted to have the possibility to make blog posts in multiple languages, both Norwegian and English. Milz’ recipe did not say how that could be done, even if her blog is multi-lingual. After a bit back and forth I ended up separating the posts folder into a “no” and “en” folder where the Norwegian and English posts should go. And then make flag (language) buttons at top of each post that directs the user to the correct post.

In retrospect I suspect there must be some more streamlined way to set up a bilingual page, because (1) I can’t see the setting “lang: en” or “lang: no” in the posts header made any difference, and (2) I know bilingualism has been a R/RStudio topic for some time now, so there is likely one or several standardized methods to use that makes sense. But I was satisfied with the solution I arrived at, for now at least, so I did not do any research to learn more.

Choosing a template and colors: I wanted to adjust the template texts and colors. It turns out there might be a bug in the template I liked best (lux). Some text in the header of blogposts appeared with black color on black background and this became invisible. I ended up with making my own template, with guidance from an AI chat tool and the Quarto blog documentation.

6. Adding a Comments Section

Adding a comments section was easier than expected. From the three alternatives highlighted in the Quarto documentation – Hypothes.is, Utterances, and Giscus – I chose Giscus. All the information I needed was in the Quarto documentation.

The only unclear part in the Quarto documentation was how each technology operates. Utterances saves comments in folders of the blog’s GitHub repository, while Giscus uses the Discussions tab of a GitHub repository of choice. Both require the use of public repositories. Since I decided to put my blog in a private Github repository, this was a problem. But I found that Giscus could be linked to a GitHub repository separate from the main blog repository. So I chose Giscus, and just created an additional public Github repository for the comments, while my main blog repository remained private.

In terms of privacy and data protection for those who choose to leave comments, they need a GitHub account, so the privacy and data protection is tied to GitHub’s privacy policies. The comments will be visible on both the blog and in the public GitHub repository connected to the blog. The owner of the GitHub repository (in this case me) can moderate discussions.

The third option for visitors’ comments that the Quarto documentation laid out, Hypothes.is, seems like a cool feature. It’s not a traditional comments section at the bottom of the page. Instead users can highlight text at a page, right-click, and add comments to the highlighted section. That could work well if you want others to review content for you. This might be something to try out later.

That’s a wrap! Please leave comments below.