Hello, Quarto!
Objective
Learn to create professional blogs, reports, and more with Quarto.
Please read excellent Quarto Guide.
Quarto is a modern, interactive publishing system built on pandoc:
origin: org-mode
(Emacs) => Sweave
/ knitr
=> RMarkdown
Identify one example to recreate during the workshop.
Quarto: A transpiler that converts markdown to various formats. The foundational technologies are:
One, Two & Three.
WARNING: Quarto is under active development!
Create a new directory for the workshop:
Create a Conda environment:
.gitignore file to git ignore conda environment:
Initialize Git:
Write a small example.md
file:
Write some markdown in a file.
code blocks: formatted but not executed in markdown.
Use 3 backticks to create code blocks in markdown & the name of the language.
Python
R
Javascript
Add code blocks to your markdown file for Python, Javascript & R.
Transpile example.md
using quarto:
Write and convert a markdown file to other format. Commit changes
Basic features:
document metadata YAML format file header:
:::
fenced blocks are used for quarto & custom css
divs and classes
::: {.class}
::: {#id}
::: {.class #id}
new branch git switch -c qmd-demo
Write a small example.qmd
file:
Render the file:
Write a .qmd
file with fenced blocks.
Quarto supports executing code blocks in markdown files.
Use curly braces {}
to specify the execution language: {python}, {r}, {julia}.
Use curly braces with a period {.}
to specify formatting options, no execution: {.python}, {.r}, {.julia}.
Python
R
#| echo: true
#| warning: false
greet <- function(name) {
print(paste("Hello", name))
}
greet("Quarto")
“Quarto”
Create a .qmd
file with a Python and R code block.
The #|
syntax adds control over code block execution & display.
Option | Description |
---|---|
#|eval |
Evaluate the code chunk. |
#|echo |
Include the source code in output. |
#|output |
Include the results of executing the code in the output (true, false, or asis). |
#|warning |
Include warnings in the output. |
#|error |
Include errors in the output. |
#|include |
Catch all for preventing any output (code or results) from being included. |
Create a .qmd
file with a Python code block using the #|
options like echo
, warning
, and eval
.
Create a Quarto blog project:
_quarto.yml
?posts/
directory?style.css
?Create a Conda environment for blog:
.gitignore file for environment:
Initialize Git:
Verify that the conda blog environment is active.
Create a new welcome.qmd
file in the posts/
folder:
---
title: "My First Blog Post"
date: 2025-01-20
---
# Welcome!
This is my first blog post using Quarto. Here's a dummy classifer on breast cancer data.
```{.python}
import urllib.request
gist_url = "https://shorturl.at/WZ8hR"
try:
with urllib.request.urlopen(gist_url) as response:
script_content = response.read().decode('utf-8')
print("Executing the script...")
exec(script_content) # Execute the script
except Exception as e:
print(f"An error occurred: {e}")
```
The preview is a live preview of the blog post in the browser. The render command generates the output file.
Preview:
Render:
posts/
directory.quarto preview & quarto render
the notebook.Write and convert a jupyter notebook to a blog post.
Configure _quarto.yml
:
Configure repo UI settings to publish from gh-pages
branch
Push to GitHub:
Merge to main
and deploy.
open -na rstudio
Create a quarto blog post using RStudio.
Form groups of 3–4 persons, have one person who is advanced in github flow.
Each group member creates a branch:
Write posts in the posts/
directory.
Merge branches to main
.
Push and share your blog URL.
Quarto Workshop