Initializing a Quarto Blog
There are several ways to start a new Quarto blog. I will use a menu driven approach using RStudio. For the following workflow you should have installed RStudio and have some knowledge how to use it.
I will not explain everything related to creating a new Quarto blog; instead, I will focus on my choices to initialize the blog.
I am using
- R version 4.4.1 (2024-06-14)
- Quarto version 1.5.54
New Project…
Inside RStudio, use the New Project…
command and select New Directory
and then Quarto Blog
.
- I am using {knitr} as the engine.
- The {renv} package is for creating reproducible environments for R projects. I will not use it as I have no experience with this complex package, and reproducibility is not an issue for my private blog (at least, I think so at the moment).
- Selecting “Use visual markdown editor” is not important, as this option is for all
.qmd
files in RStudio always available. I think that this option only controls the default behavior whenever a new file for a post is created.
Key Files
Clicking the “Create Project” button generates different key files and opens the _quarto.yml
file in the RStudio editor window.
If you can’t see all five files starting with a dot (so-called dotfiles) in your installation, go to the drop-down menu ‘More’ and check the last option ‘Show Hidden Files’.
Here’s a summary of the key files created within the starter blog project:
File | Description |
---|---|
_quarto.yml |
Quarto project file. |
index.qmd |
Blog home page. |
about.qmd |
Blog about page. |
posts/ |
Directory containing posts |
posts/_metadata.yml |
Shared options for posts |
styles.css |
Custom CSS for website |
Content of the Quarto Project File
Here is the content of _quarto.yml
:
_quarto.yml
project:
type: website
website:
title: "quarto-pb-blog"
navbar:
right:
- about.qmd
- icon: github
href: https://github.com/
- icon: twitter
href: https://twitter.com
format:
html:
theme: cosmo
css: styles.css
Content of the Blog Home Page
Here is the content of index.qmd
:
index.qmd
title: "quarto-pb-blog"
listing:
contents: posts
sort: "date desc"
type: default
categories: true
sort-ui: false
filter-ui: false
page-layout: full
title-block-banner: true
---
Render Blog
You can control via Tools->Global Options…->R Markdown->Show output preview in…
whether the rendered result appears in the browser window or in the viewer pane. Generally, I use the “Window” option because it gives me a better view of the real setting.
RStudio console output
==> quarto preview index.qmd --to html --no-watch-inputs --no-browse
pandoc to: html
output-file: index.html
standalone: true
title-prefix: quarto-pb-blog
section-divs: true
html-math-method: mathjax
wrap: none
default-image-extension: png
css:
- styles.css
metadata
document-css: false
link-citations: true
date-format: long
lang: en
theme: cosmo
title: quarto-pb-blog
listing:
contents: posts
sort: date desc
type: default
categories: true
sort-ui: false
filter-ui: false
page-layout: full
title-block-banner: true
WARN: Unable to read listing item description from posts/post-with-code/index.html
WARN: Unable to read listing item description from posts/welcome/index.html
WARN: Unable to read listing preview image from posts/welcome/index.html
Output created: _site/index.html
Preparing to preview
[1/4] posts/post-with-code/index.qmd
R version 4.4.1 (2024-06-14)
processing file: index.qmd
output file: index.knit.md
[2/4] posts/welcome/index.qmd
[3/4] about.qmd
[4/4] index.qmd
Watching files for changes
Browse at http://localhost:5146/
GET: /
As you can see in the above console output I got three warnings:
- Unable to read listing item description from posts/post-with-code/index.html
- Unable to read listing item description from posts/welcome/index.html
- Unable to read listing preview image from posts/welcome/index.html
These warnings are prompted by the fact that we need to render the complete blog with SHIFT-CMD-B or by clicking “Render Website” after choosing the “Build” button on the upper right RStudio pane. I will explain render strategies in a later post.
Summary
This is the end of the initialization process. In later blog posts I will add more functionality and style the web page it to get a more attractive appearance of the Quarto blog.