Skip to content

Commit 1dc8ace

Browse files
authored
Merge pull request #4 from pythonhealthdatascience/dev
Dev
2 parents df57eae + 90f50f2 commit 1dc8ace

79 files changed

Lines changed: 1969 additions & 592 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

_quarto.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,25 @@ website:
2121
contents:
2222
- text: Welcome
2323
href: index.qmd
24-
- pages/why.qmd
24+
- text: "Slides: Why make a website for your research?"
25+
href: pages/why/index.qmd
2526
- section: "Tutorial"
2627
contents:
27-
- pages/setup.qmd
28-
- pages/basic_structure.qmd
29-
- pages/making_a_change.qmd
30-
- pages/markdown.qmd
31-
- pages/quarto_features.qmd
32-
- pages/media.qmd
33-
- pages/inline_html.qmd
34-
- pages/customising.qmd
35-
- pages/code.qmd
36-
- pages/summary.qmd
37-
- pages/examples.qmd
28+
- pages/setup/index.qmd
29+
- pages/basic_structure/index.qmd
30+
- pages/making_a_change/index.qmd
31+
- pages/markdown/index.qmd
32+
- pages/quarto_features/index.qmd
33+
- pages/media/index.qmd
34+
- pages/inline_html/index.qmd
35+
- pages/customising/index.qmd
36+
- pages/task/index.qmd
37+
- section: "Optional extras"
38+
contents:
39+
- pages/blog/index.qmd
40+
- pages/sass_css/index.qmd
41+
- pages/code/index.qmd
42+
- pages/examples/index.qmd
3843
page-footer:
3944
center:
4045
- text: |
@@ -44,10 +49,11 @@ website:
4449
format:
4550
html:
4651
number-sections: true
52+
lightbox: true
4753
theme:
4854
- cosmo
4955
- styles/theme.scss
5056
css:
5157
- styles/styles.css
5258
include-after-body:
53-
- styles/autopreview.html
59+
- styles/slideshow.js
471 KB
Loading

pages/basic_structure.qmd

Lines changed: 0 additions & 178 deletions
This file was deleted.

pages/basic_structure/index.qmd

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
title: Basic structure
3+
---
4+
5+
::: {.pale-blue}
6+
7+
**On this page we will:**
8+
9+
* Understand the two core files in a basic Quarto website.
10+
* Learn how to render and preview the website.
11+
12+
:::
13+
14+
<br>
15+
16+
We'll be creating a **Quarto website**. A simple website project just needs two key files:
17+
18+
1. `_quarto.yml`
19+
2. `index.qmd`
20+
21+
## `_quarto.yml`
22+
23+
This is file defines your **project settings** and **website structure**.
24+
25+
The file uses YAML, which is just a plain text format for settings, written as **key: value** pairs, for example `title: My website`. Indentation (spaces at the start of a line) shows that something belongs "inside" something else, a bit like folders within folders.
26+
27+
Below is an example from [quarto-template](https://github.com/pythonhealthdatascience/quarto-template){target="_blank"}. Hover over each line to see an explanation:
28+
29+
```yaml
30+
project: # <1>
31+
type: website # <1>
32+
33+
website: # <1>
34+
title: "Quarto Template" # <2>
35+
navbar: # <3>
36+
right: # <4>
37+
- icon: github # <4>
38+
text: GitHub # <4>
39+
href: https://github.com/pythonhealthdatascience/quarto-template/ # <4>
40+
sidebar: # <5>
41+
- logo: images/exeter.png # <6>
42+
contents: # <7>
43+
- text: Overview # <7>
44+
href: index.qmd # <7>
45+
- pages/1_making_a_change.qmd # <7>
46+
- pages/2_markdown_basics.qmd # <7>
47+
- pages/3_quarto_features.qmd # <7>
48+
- pages/4_images_videos_documents.qmd # <7>
49+
- pages/5_inline_html.qmd # <7>
50+
51+
format: # <8>
52+
html: # <8>
53+
theme: default # <8>
54+
```
55+
56+
1. **Website:** Defines that this project builds as a website.
57+
2. **Website title:** Appears in broswer tab and navbar.
58+
3. **Navbar:** The navigation bar across the top of your site.
59+
4. **GitHub link:** Adds a GitHub icon on the right side of the navbar linking to the repository (which contains the source files for the site).
60+
5. **Sidebar:** Displays navigation links down the left-hand side.
61+
6. **Logo:** The image shown at the top of the sidebar.
62+
7. **Sidebar contents:** Lists website pages. Will list using page titles by default, but can override with `text` (title to use) and `href` (path to file).
63+
8. **Theme:** Site theme (covered on [Customising the site appearance](/pages/customising/index.qmd) page).
64+
65+
::: {.callout-note title="Optional extra: books" collapse="true"}
66+
67+
A **Quarto book** is basically a website with chapter-style navigation. Under the hood, it's still a Quarto website - just organised a little differently.
68+
69+
See the [books guide](https://quarto.org/docs/books/book-output.html) for more information.
70+
71+
Example:
72+
73+
```yaml
74+
project:
75+
type: book
76+
77+
book:
78+
title: "Quarto Template"
79+
favicon: images/exeter.png
80+
chapters:
81+
- text: Overview
82+
href: index.qmd
83+
- pages/TODO.qmd
84+
navbar:
85+
right:
86+
- icon: github
87+
text: GitHub
88+
href: https://github.com/pythonhealthdatascience/quarto-template/
89+
sidebar:
90+
logo: images/exeter.png
91+
```
92+
93+
:::
94+
95+
## `index.qmd`
96+
97+
A `.qmd` file is a **Quarto Markdown** document. It mixes metadata at the top, text, and (optionally) code. For a website, `index.qmd` is treated as the **homepage:** when someone visits the root of your site, Quarto serves `index.html`, which comes from `index.qmd.
98+
99+
> If you're familiar with R Markdown (`.Rmd`), these are similar, but `.qmd` is more flexible.
100+
101+
Each `.qmd` file begins with **YAML front matter**, enclosed by three dashes (`---`). This defines metadata such as the page title. Below that is the page. Here we just have one sentence: `This is my homepage.`.
102+
103+
```{.r}
104+
---
105+
title: My homepage
106+
---
107+
108+
109+
This is my homepage.
110+
```
111+
112+
## Rendering your website
113+
114+
**Rendering** means converting your Quarto source files into the final website - a collection of `.html` pages that live inside a folder called `_site`. To render your site:
115+
116+
1. Open `index.qmd` in the editor, and click the **Preview** button in the top right hand corner
117+
118+
![](preview_button.drawio.png){fig-alt="Screenshot of VSCode with Preview button circled."}
119+
120+
2. In the bottom panel in the Terminal, you should see it says **Preparing to preview** and runs through files. It is creating `_sites/` folder containing your rendered site. Then when it is done, green text saying `Browse at ...`.
121+
122+
![](preparing_preview.png){fig-alt="Screenshot of the 'Preparing to preview' message in the Terminal."}
123+
124+
3. You are now viewing a **live preview** of your site in the browser. Nothing is public yet; this preview only runs on your own computer. In other words, you are the only person who can see this site right now, and it will not appear on the internet until you deliberately publish or upload the rendered files somewhere.
125+
126+
By default, VSCode will open the preview in-line. This will be quite a small preview - to open it in a new tab, either copy the URL from the Terminal (`http://localhost:...`) or click the "Open in Browser" button in the top right.
127+
128+
![](inline.png){fig-alt="Screenshot of preview opened in-line, with cursor hovering over the 'Open in Browser' button."}
129+
130+
<br>
131+
132+
133+
134+
::: {.callout-note title="Optional extra: rendering via the terminal" collapse="true"}
135+
136+
Alternatively, you can render and preview your site directly via commands in the terminal.
137+
138+
In the bottom panel, ensure you are on the **Terminal** tab. The Terminal is a place where you type commands instead of clicking buttons. We just need to type `quarto preview` then press <kbd>Enter</kbd> on your keyboard.
139+
140+
![](preview_terminal.drawio.png){fig-alt="Screenshot of VSCode with 'quarto preview' command in Terminal circled."}
141+
142+
You can then use the `http://localhost:...` link printed in the Terminal to open your site in the browser.
143+
144+
With this method, the site updates automatically whenever files are saved. In Codespaces, files are auto‑saved very frequently, so the preview will re-render often; for that reason, the **Preview** button described above is usually a calmer option during this workshop.
145+
146+
:::

pages/basic_structure/inline.png

187 KB
Loading
47.6 KB
Loading

pages/basic_structure/preview_button.drawio

Lines changed: 19 additions & 0 deletions
Large diffs are not rendered by default.
441 KB
Loading
163 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel>

0 commit comments

Comments
 (0)