Skip to content

Commit 5aa5769

Browse files
committed
Quarto website resources
* Create a Quarto section in the resources. * Update content for week 9.
1 parent 8753802 commit 5aa5769

10 files changed

Lines changed: 180 additions & 11 deletions

File tree

_freeze/resources/quarto-docs/execute-results/html.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

_quarto.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ website:
129129
file: resources/rstudio-setup.qmd
130130
- text: "Using R in RStudio"
131131
file: resources/rstudio-guide.qmd
132-
- text: "Quarto documents"
133-
file: resources/quarto-docs.qmd
134132
- text: "Importing data"
135133
file: resources/importing.qmd
136134
- text: "Visualization with ggplot2"
@@ -149,6 +147,12 @@ website:
149147
file: resources/git-workflow.qmd
150148
- text: "Git Glossary"
151149
file: resources/git-glossary.qmd
150+
- section: "Quarto"
151+
contents:
152+
- text: "Quarto documents"
153+
file: resources/quarto-docs.qmd
154+
- test: "Quarto websites"
155+
file: resources/quarto-websites.qmd
152156

153157
page-footer:
154158
right: |

content/08-content-git.qmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ format: html
2727
- Think about setting goals for the rest of the semester.
2828

2929
## Activities
30-
- Discussion of your data analysis project
3130
- Getting familiar with the command line
3231
- Getting started with git
3332
- Working with git and GitHub in RStudio

content/09-content-quarto.qmd

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ Mine Çetinkaya-Rundel & Julia Stewart Lowndes, Hello Quarto: Share, Collaborate
2525
- Practice writing some R code.
2626

2727
## Activities
28-
28+
- Git and GitHub check in
29+
- Quarto documents with SNiGB data
30+
- Static websites
31+
- Quarto websites
2932

3033
## Resources
31-
- [Quarto: Creating a website](https://quarto.org/docs/websites/)
34+
35+
### Quarto resources
36+
- [Elen Le Foll, Quarto for reproducible research workflows and academic publishing](https://elenlefoll.quarto.pub/quarto4research/)
37+
- [Branded Websites, Presentations, Dashboards, and PDFs with Quarto posit::conf(2025) workshop](https://posit-conf-2025.github.io/quarto-brand/)
38+
- Quarto documentation: [Creating a website](https://quarto.org/docs/websites/)
39+
- Quarto documentation: [HTML Documents](https://quarto.org/docs/output-formats/html-basics.html)
40+
41+
### DH and static websites
42+
- *Digital Humanities Quarterly* special issue on [Minimal Computing](https://dhq.digitalhumanities.org/vol/16/2/index.html).
43+
- [Lib-Static](https://lib-static.github.io).

files/img/gh-pages-deploy.png

473 KB
Loading

files/img/quarto-web-create.png

78.3 KB
Loading

files/img/quarto-web-files.png

110 KB
Loading

files/img/quarto-web-preview.png

160 KB
Loading

resources/quarto-docs.qmd

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The rest of this page goes over the foundations of Quarto documents, but there a
2525
## Quarto foundations
2626
A Quarto document is a plain text file that has a `.qmd` extension. It contains three basic components:
2727

28-
1. A [YAML header](https://en.wikipedia.org/wiki/YAML) contained within lines with three dashes (---).
28+
1. A [YAML header](https://en.wikipedia.org/wiki/YAML) contained within lines with three dashes (`---`).
2929
2. Markdown text.
3030
3. Code chunks set off by three back ticks (```).
3131

@@ -69,10 +69,10 @@ execute:
6969
---
7070
```
7171

72-
The available keys can be found in the documentation for each type of output. Many options are shared across document output types, but some are not. See the [HTML options](https://quarto.org/docs/reference/formats/html.html) for the widest number of options. It can be difficult to write these YAML headers, but happily in practice it is unlikely to be as difficult it looks. Firstly, you will not need to write complex YAML headers often. Secondly, you can figure out settings that work for you and then copy and paste them into other documents. There are also ways for YAML options to be used for all documents in a [project](https://quarto.org/docs/projects/quarto-projects.html) such as a website.
72+
The available keys can be found in the documentation for each type of output.[^1] Many options are shared across document output types, but some are not. See the [HTML options](https://quarto.org/docs/reference/formats/html.html) for the widest number of options. It can be difficult to write these YAML headers. There are a lot of different options, and the indentation level must be formatted correctly. Happily, in practice, it is unlikely to be as difficult it looks. Firstly, you will not need to write complex YAML headers often. Secondly, you can figure out settings that work for you and then copy and paste them into other documents. There are also ways for YAML options to be used for all documents in a [project](https://quarto.org/docs/projects/quarto-projects.html) such as a website.
7373

7474
### 2. Markdown
75-
Unlike R scripts where default text is code, the default text in Quarto documents is Markdown. Use [Resources: Markdown syntax](markdown-syntax.qmd) for Markdown foundations, and look at the [Quarto Markdown documentation](https://quarto.org/docs/projects/quarto-projects.html) for more details on the style of Markdown you can use in Quarto documents.
75+
Unlike R scripts where default text is code, the default text in Quarto documents is Markdown. Use [Resources: Markdown syntax](markdown-syntax.qmd) for Markdown foundations, and look at the [Quarto Markdown documentation](https://quarto.org/docs/authoring/markdown-basics.html) for more details on the style of Markdown you can use in Quarto documents.
7676

7777
### 3. Code chunks
7878
With Markdown as the default editing environment, your code must be placed in code chunks set off by three back ticks (```). They look like this:
@@ -117,5 +117,26 @@ The other options you might want to change are the **figure output**. See [*R fo
117117
- `out-width: "70%"`: This would take up 70% of the content area.
118118
- `fig-align: center`: How to align the plots.
119119

120+
## Output formats
121+
You can create a number of different types of documents from Quarto documents. The default is HTML documents ready to be put on the web or viewed through your browser, but you can also make [PDFs](https://quarto.org/docs/output-formats/pdf-basics.html), [presentations](https://quarto.org/docs/presentations/), [dashboards](https://quarto.org/docs/dashboards/), and even [Word documents](https://quarto.org/docs/output-formats/ms-word.html). It is also possible to combine multiple Quarto documents together into [projects](https://quarto.org/docs/projects/quarto-projects.html) such as [websites](https://quarto.org/docs/websites/) and [books](https://quarto.org/docs/books/).
122+
123+
You control the output of individual documents either in the document YAML or in rendering the document via the command line. Generally, you will want to use the document YAM using the `format` key.
124+
125+
- HTML: `format: html`
126+
- PDF: `format: pdf` or `format: typst`
127+
- Presentation: `format: revealjs`
128+
- Word: `format: docx`
129+
130+
Most options within the YAML are shared across output formats, but not all formats have all the capabilities. Look at the [reference documentation](https://quarto.org/docs/reference/) for each type to see the available options.
131+
132+
### A note on PDF formats
133+
If you want to output a PDF, you have two different choices, `format: pdf` uses [Pandoc](https://pandoc.org) to create the PDF; `format: typst` uses [Typst](https://typst.app). The Pandoc format has more options, but Typst is a more modern PDF engine and has nicer looking defaults.
134+
135+
### Project outputs
136+
Projects contain multiple Quarto documents and use a `_quarto.yml` file to share the YAML metadata options across all of the documents within the project. If you want different YAML options in one or more documents within the project, you can modify the YAML in the document itself. The options written in the document will take precedence over those written in the `_quarto.yml` file. This means that generally the YAML heading for individual documents in a project might only have a title. See [Quarto websites](quarto-websites.qmd) for more on working with Quarto projects.
137+
120138
## Conclusion
121-
This is just the tip of the iceberg for what you can do with Quarto documents. But you can do a lot with these foundations. Check out the [Resources](#resources) above for places to start if this document does not cover a question you have.
139+
This is just the tip of the iceberg for what you can do with Quarto documents. But you can do a lot with these foundations. Check out the [Resources](#resources) above for places to start if this document does not cover a question you have.
140+
141+
142+
[^1]: See the [Output formats](#output-formats) section for more details on output formats.

resources/quarto-websites.qmd

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
title: "Quarto websites"
3+
format: html
4+
---
5+
6+
[Quarto websites](https://quarto.org/docs/websites/) are a collection of Quarto documents using `format: html` with a set structure and consistent visual style. This page will guide you through setting up a Quarto website project, outline some of the structures and features of Quarto websites, and show how to deploy a Quarto website to the internet using GitHub Pages.
7+
8+
## Resources
9+
The Quarto documentation is the best place to look when you have a question. The documentation will be linked extensively below, but the most important pages are:
10+
11+
- [Creating a website](https://quarto.org/docs/websites/)
12+
- [Website navigation](https://quarto.org/docs/websites/website-navigation.html)
13+
- [HTML basics](https://quarto.org/docs/output-formats/html-basics.html)
14+
- [HTML theming](https://quarto.org/docs/output-formats/html-themes.html)
15+
- [Publishing to GitHUb Pages](https://quarto.org/docs/publishing/github-pages.html)
16+
17+
Posit has also created a YouTube series on [building a Quarto website](https://youtu.be/l7r24gTEkEY?si=QGzhARrLgHJ-gpxk). This series also discusses making a [blog with Quarto](https://quarto.org/docs/websites/website-blog.html). A blog is a Quarto website that has some additional features to allow you to have a page listing the blog posts. Otherwise, there is a great deal of overlap.
18+
19+
### Examples of Quarto websites
20+
There are a lot of Quarto websites out in the world. A couple that you might want to look at include:
21+
22+
- The website for [this class](https://jessesadler.github.io/vt5444s26/) is a Quarto website.
23+
- [OpenScapes](https://openscapes.org)
24+
- [Andrew Heiss](https://www.andrewheiss.com/)
25+
- [Ted Laderas](https://laderast.github.io)
26+
- [Affective Communication & Computing Lab](https://affcom.ku.edu)
27+
28+
## Creating a Quarto website
29+
Creating a website with RStudio is done in the same way as creating a new project. Go to File -> New Project... or click on New Project in the Project dropdown at the top-right of RStudio. See [Setting up RStudio for success](rstudio-setup.qmd#rstudio-projects) for more details. When in the New Project dialogue window, select New Directory, and then under Project Type choose Quarto Website as in @fig-website-create. Give the new project folder a name, remembering the naming guidelines, and place it in your `vt5444s26` folder. This will be an example website, so do not worry about the name right now. You can also
30+
31+
![Create a Quarto website project.](../files/img/quarto-web-create.png){#fig-website-create width=50% fig-alt="A screen shot of the RStudio new project wizard with an orange box highlighting the selection of Quarto website as the type of project."}
32+
33+
RStudio will start up a new session in your new project folder with a few template documents to get you started on your website as shown in @fig-website-files.
34+
35+
![Project files for a freshly created Quarto website project.](../files/img/quarto-web-files.png){#fig-website-files width=50% fig-alt="A screen shot of RStudio showing the files created by making a new Quarto website project. The files are: _quarto.yml, .gitignore, about.qmd, index.qmd, an Rproj file, and styles.css."}
36+
37+
## Render and preview your website
38+
Click on the `Render` button at the top of the RStudio editor panel to [build your website and preview what it looks like](https://quarto.org/docs/websites/#website-preview). This can also be done by running the command `quarto preview` in the Terminal.[^1] When the website is rendered, a new `_site` folder will be created. This folder contains all of the HTML files that make up your website. You will also see the preview of the site open in the View panel on the right. You can click on the Show in new window button as shown in @fig-website-preview to open the preview in your browser.
39+
40+
![Preview of the newly created Quarto website.](../files/img/quarto-web-preview.png){#fig-website-preview width=50% fig-alt="A screen shot of the Viewer panel in RStudio showing a preview of the newly created website. There is a purple arrow pointing to the external viewer button."}
41+
42+
Open up `index.qmd` and make some changes to the text. Save the file and then click on Render, or check the box for Render on save, and see what happens. The website updates with the new content. This is the basic workflow for working on a Quarto website. Make some changes and then see what they look like by previewing them.
43+
44+
## How Quarto websites work
45+
Let's now dig into the files that were created with the website project to understand a bit more about the different types of files and how they work to create a website. There are three types of files in the website template that represent the three main types of files used to create a Quarto website.
46+
47+
1. Quarto documents: Each document is a web page.
48+
2. `_quarto.yml`: Configuration file that determines the structure of the website and website wide settings.
49+
3. A CSS or SCSS style sheet that sets the style for the website.
50+
51+
Let's go through these one by one.
52+
53+
### 1. Quarto documents
54+
Each document is a web page. `index.qmd` and `about.qmd` are special pages. All other Quarto documents are other web pages. See the [HTML documents](https://quarto.org/docs/reference/formats/html.html) documentation on options for HTML documents.
55+
56+
- `index.qmd` is the home page.
57+
- `about.qmd` is about page that has some special themes.
58+
59+
The YAML heading for each document can be very simple because `_quarto.yml` can be used to set the options for the whole site.
60+
61+
### 2. Configuration file
62+
`_quarto.yml` is a YAML file that determines the structure of the website and sets website wide options. The [Website navigation](https://quarto.org/docs/websites/website-navigation.html) documentation shows the different options for setting up the structure of the website. You can use a [top navigation bar](https://quarto.org/docs/websites/website-navigation.html#top-navigation), a [side bar](https://quarto.org/docs/websites/website-navigation.html#side-navigation), or a [combination of the two](https://quarto.org/docs/websites/website-navigation.html#hybrid-navigation).
63+
64+
The `_quarto.yml` configuration file can also be used to set website-wide options for the webpages such as whether to include a table of contents or the numbering of sections among many others. See the [HTML options page](https://quarto.org/docs/reference/formats/html.html) for a complete list of choices available to you.
65+
66+
### 3. Styles and theme
67+
The [HTML theming](https://quarto.org/docs/output-formats/html-themes.html) and [More about themes](https://quarto.org/docs/output-formats/html-themes-more.html) documentation goes into the details on styling you website.
68+
69+
Quarto websites use a base theme that is set within the `_quarto.yml` configuration file. Quarto themes are based on the 25 [bootswatch](https://bootswatch.com/) themes, which can be set under the `theme` key. You can also set important [base styling options](https://quarto.org/docs/output-formats/html-themes.html#basic-options) within the `_quarto.yml` file.
70+
71+
But, if you want to alter any aspect of the style of you website, you can do so using CSS (Cascading Style Sheets). However, Quarto is set up to use [Sass](https://sass-lang.com) or a `.scss` file. See the [Sass variables](https://quarto.org/docs/output-formats/html-themes.html#sass-variables) documentation on how to change styling options with a `.scss` file.
72+
73+
## Deploying Quarto websites to GitHub Pages
74+
These instructions show how to deploy a Quarto website to GitHub pages using a GitHub Action. See the [instructions here](https://quarto.org/docs/publishing/github-pages.html) from the Quarto documentation for more details. GitHub pages uses a special `gh-pages` branch to host static websites created by tools such as Quarto.
75+
76+
1. Set up local repository to use GitHub Actions
77+
1. Add `/.quarto/` and `/_site/` to `.gitignore` file.
78+
- The `_site/` folder is created from the Quarto files and will be created by the GitHub action set up in step 7.
79+
2. Set `freeze: auto` in `_quarto.yml`.
80+
- This makes it so Quarto will only rerender a file if it has changed, making the preview and render workflow faster. See the documentation on use of [freeze](https://quarto.org/docs/projects/code-execution.html#freeze).
81+
3. Render site to create a `_freeze` folder.
82+
4. Add and commit files.
83+
2. Create connection to GitHub using [Local first method](git-workflow.qmd#local-first)
84+
1. Create empty repository on GitHub with the same name as your website project.
85+
2. Add remote with `git remote add origin your-url-here`
86+
3. Push and `set-upstream` to GitHub: `git push --set-upstream origin main`
87+
3. Create `gh-pages` branch on local repository
88+
- Make sure you have committed all changes to your current working branch with `git status`.
89+
- Close all of your tabs in RStudio. The following actions will delete all of your files on the new branch. This is ok!
90+
91+
```bash
92+
git checkout --orphan gh-pages
93+
git reset --hard # make sure all changes are committed before running this!
94+
git commit --allow-empty -m "Initialising gh-pages branch"
95+
git push origin gh-pages
96+
```
97+
98+
4. Switch back to main branch
99+
100+
```bash
101+
git switch main
102+
```
103+
104+
5. Check GitHub Pages setup
105+
- Go to GitHub
106+
- Click on the Branches dropdown in the upper left that should say main and then click View all branches.
107+
- Go to Settings -> Pages
108+
- check that the Source branch for your repository is `gh-pages` and that the site directory is set to the `/(root)` repository as shown in @fig-gh-pages.
109+
6. Make first publish
110+
- Make sure you are on your `main` branch. You can check this in the Git Tab of RStudio or by running `git branch` in the Terminal.
111+
- Run `quarto publish gh-pages` in the Terminal and then enter Y for yes.
112+
7. Add GitHub publish action
113+
- Add `.github/workflows/publish.yml` copying from the [Publish action](https://quarto.org/docs/publishing/github-pages.html#publish-action) in the Quarto documentation.
114+
- Add and commit the new file.
115+
8. Push your project to GitHub
116+
- Make a push to GitHub: `git push`.
117+
- You should now be able to return to the repository page on GitHub and see an Action running. Click on the Action tab to see the progress.
118+
- If the action runs correctly, the website should be online and updated.
119+
- In the repository page on GitHub click on the gear button in the About section on the right. Click on the box to use your GitHub pages website as the url of the project. This will make it easier to click over to your website.
120+
121+
![Make sure that your GitHub Pages branch is correctly set up.](../files/img/gh-pages-deploy.png){#fig-gh-pages width=75% fig-alt="A screen shot of GitHub showing how to get to the GitHub Pages web page through Settings and Pages."}
122+
123+
## The website workflow
124+
With the GitHub Action set up the website workflow is largely the same as the normal Git and GitHub workflow with one minor change. You should make sure to preview and render your changes before making a push to GitHub.
125+
126+
1. Make changes to your website project.
127+
2. Preview the website to see that everything works and to ensure that the `_freeze` folder is updated.
128+
3. Add and commit the local changes.
129+
4. Repeat steps 1–3.
130+
5. Push to GitHub to make your changes live to your website.
131+
132+
133+
[^1]: Quarto is first and foremost a command line tool. Therefore, all of the commands you run in RStudio can also be done in the Terminal.

0 commit comments

Comments
 (0)