Repository navigation
Expand file tree
/
Copy pathREADME.Rmd
More file actions
416 lines (291 loc) Β· 14.1 KB
/
Copy pathREADME.Rmd
File metadata and controls
416 lines (291 loc) Β· 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
# qwt ([Q]{.underline}uarto [W]{.underline}ebsite [T]{.underline}emplate)
<!-- badges: start -->
<!-- badges: end -->
A template repository for creating websites with [Quarto](https://quarto.org/).
This template provides everything you need to quickly start writing your own website.
## Features
- π **Website-ready structure** with sample chapters and references
- π¨ **Customizable themes** supporting light and dark modes
- π **Automatic deployment** to GitHub Pages via GitHub Actions
- π **Automated link checking** to ensure all URLs are reachable
- π **Multiple output formats** including HTML, PDF, RevealJS slides, and DOCX
- π **Bibliography support** with BibTeX integration
- π’ **Automatic numbering** of sections and cross-references
- π
**Custom CSS** for styling your website
- π **PR Preview** with change highlighting for pull requests
- β
**Automated checks** including spell checking and linting
- π€ **GitHub Copilot integration** with custom setup steps
## Quick Start
### Using this template
1. Click the "Use this template" button at the top of this repository
2. Name your new repository and create it
3. Clone your new repository to your local machine
```bash
git clone https://github.com/YOUR-USERNAME/YOUR-REPO.git
cd YOUR-REPO
```
### Prerequisites
You need to have [Quarto](https://quarto.org/) installed. Download it from [quarto.org/docs/get-started](https://quarto.org/docs/get-started/).
To verify Quarto is installed:
```bash
quarto --version
```
**Minimum version:** This template uses Quarto's [`llms-txt`](https://quarto.org/docs/websites/website-llms.html) website option, which requires **Quarto 1.9.36 or newer** (the version this template was verified on). Earlier Quarto versions do not recognize `llms-txt` as a valid `website:` property and will produce a schema error when rendering.
### Customize your website
A new repository starts with this template's name, links, and placeholder author.
The **Check template identity** workflow fails until you replace each of these values:
| Value | File | Field |
| --- | --- | --- |
| `Quarto Website Template` | `_quarto-website.yml` | `website: title` |
| `Quarto Website Template` | `index.qmd` | `title`, and the opening sentence |
| `Quarto Website Template` | `DESCRIPTION` | `Title` |
| `https://morrison-lab.github.io/qwt/` | `_quarto-website.yml` | `website: site-url` |
| `https://github.com/Morrison-Lab/qwt` | `_quarto-website.yml` | `website: repo-url`, and the navbar GitHub link |
| `https://github.com/Morrison-Lab/qwt` | `DESCRIPTION` | `URL` and `BugReports` |
| `Your Name` and `your.email@example.com` | `DESCRIPTION` | `Authors@R` |
The check ignores letter case, so "Quarto website template" in the opening sentence of `index.qmd` counts too.
Then make the rest your own:
1. **Edit `_quarto-website.yml`** to update:
- Navigation menu items
- Theme and styling options
2. **Modify `index.qmd`** to create your website's homepage
3. **Edit or create pages** (`.qmd` files):
- Modify files in the `chapters/` directory as needed
- Create new pages and add them to the navigation menu and the sidebar in `_quarto-website.yml`
4. **Add references** to `references.bib` in BibTeX format
5. **Customize styling** in `styles.css`
## Building the website
### Local preview
To preview your website with live reload during development:
```bash
quarto preview
```
This will open your website in a web browser and automatically refresh when you make changes.
### Render the website
To render the complete website:
```bash
quarto render
```
The output will be generated in the `_site/` directory.
### Multiple output formats
This template supports multiple output formats in a single render:
- **Website pages** (`.html`)
- **RevealJS slides** (`-slides.html`)
- **PDF handouts** (`-handout.pdf`)
- **DOCX documents** (`.docx`)
## Publishing to GitHub Pages
This template includes a GitHub Actions workflow (`.github/workflows/publish.yml`) that automatically builds and publishes your website to GitHub Pages when you push to the main branch.
### Setup steps:
1. **Enable GitHub Pages** in your repository:
- Go to Settings β Pages
- Under "Build and deployment", set Source to "GitHub Actions"
2. **Push to main branch**:
```bash
git add .
git commit -m "Initial website setup"
git push origin main
```
3. **Apply branch rulesets** (requires admin access):
```bash
.github/scripts/apply-rulesets.sh
```
This protects `main` against direct pushes / force-pushes / deletion and
requires a PR to merge. See `.github/rulesets/README.md` for details.
4. **Wait for the workflow** to complete (check the Actions tab)
5. **Access your website** at: `https://YOUR-USERNAME.github.io/YOUR-REPO/`
## GitHub Actions Workflows
This template includes several automated workflows to enhance your development experience:
### π Publish Workflow (`publish.yml`)
Automatically builds and deploys your website to GitHub Pages when you push to the main branch. It also saves the Quarto freezer (`_freeze`) cache for reuse by preview builds.
**Triggers:** Push to main branch, manual dispatch
### π PR Preview Workflows (`preview.yml`, `preview-deploy.yml`)
`preview.yml` builds the preview read-only and `preview-deploy.yml` publishes it to `gh-pages` and comments the link.
Both call the shared workflows in [`Morrison-Lab/gha`](https://github.com/Morrison-Lab/gha), and `publish.yml` calls its `quarto-publish.yml`.
Previews start working once `preview-deploy.yml` is on `main`.
Creates a preview deployment for pull requests with:
- Change detection and highlighting
- DOCX files with tracked changes
- Visual indicators for modified chapters
- Banner showing what changed in the PR
- Reuse of the Quarto freezer cache with updates saved per PR commit
**Triggers:** PR opened, reopened, synchronized, closed, labeled, or unlabeled
A preview renders every format `_quarto.yml` declares (HTML, slides, PDF handouts and Word), so no label is needed for those.
**Labels:**
- Add `no-preview-highlights` to disable change highlighting if it's glitchy
- Add `clear freezer` to render without restoring the `_freeze` cache (a label with this exact name, space included, must exist on the repository before it can be applied)
### β
Spell Check Workflow (`check-spelling.yaml`)
Runs automated spell checking on pushes and pull requests to maintain content quality.
**Triggers:** Push to main, pull requests
### π Lint Project Workflow (`lint-project.yaml`)
Checks R code style and quality using the lintr package.
**Triggers:** Push to main/master, pull requests
**Note:** Only runs if your project contains R code.
### π€ Copilot Setup Steps (`copilot-setup-steps.yml`)
Configures the GitHub Copilot coding agent's environment for:
- Quarto
- TinyTeX
- Optional GitHub CLI authentication for
`https://github.com/Morrison-Lab/macros` (via the `MACROS_REPO_PAT`
repository or organization Actions secret; includes a write
permission check during setup)
**Triggers:** Workflow dispatch, changes to the setup file
### π Check Bibliography DOIs Workflow (`check-bibliography-dois.yml`)
Validates that all books and articles in bibliography files meet DOI requirements:
- Every book and article must have a DOI field
- Every DOI must resolve to a valid URL
- Reference information is checked against DOI metadata for consistency
**Triggers:** Push to main, pull requests, manual dispatch
**Note:** This helps maintain high-quality bibliographic references and ensures all citations are properly traceable.
### πͺͺ Check Template Identity Workflow (`check-template-identity.yml`)
Fails in a repository made from this template while its files still hold the values listed under [Customize your website](#customize-your-website).
In `Morrison-Lab/qwt` itself it passes with a notice.
**Triggers:** Push to main, pull requests, manual dispatch
## Project Structure
```
.
βββ _quarto.yml # Main configuration file
βββ _quarto-website.yml # Website-specific configuration
βββ index.qmd # Website homepage
βββ chapters/ # Chapter files
β βββ chapter1.qmd # Sample chapter 1
β βββ chapter2.qmd # Sample chapter 2
βββ references.qmd # References page
βββ references.bib # BibTeX bibliography
βββ styles.css # Custom CSS styles
βββ page-navigation.html # Previous/next margin arrows and navbar highlighting
βββ lychee.toml # Link checker configuration
βββ .gitignore # Git ignore file
βββ LICENSE # CC0 1.0 Universal License
βββ README.md # This file
βββ latex-macros/ # Git submodule: Morrison-Lab/macros
βββ .github/
βββ rulesets/ # Branch ruleset definitions
β βββ main.json # Default branch ruleset
β βββ README.md # Ruleset documentation
βββ scripts/ # Scripts for workflows
β βββ add-page-banners.py # Per-page preview banners (gha#1025)
β βββ apply-rulesets.sh # Apply branch rulesets to a new repo
βββ workflows/ # GitHub Actions workflows
βββ publish.yml # Build and deploy to GitHub Pages
βββ preview.yml # PR preview with change highlighting
βββ preview-deploy.yml # Publish the PR preview to gh-pages
βββ check-spelling.yaml # Spell checking
βββ lint-project.yaml # R code linting
βββ copilot-setup-steps.yml # GitHub Copilot setup
βββ check-links.yml # URL reachability checker workflow
βββ check-bibliography-dois.yml # Bibliography DOI validation
```
## Automated Workflows
This template includes two GitHub Actions workflows:
### Publishing Workflow (`publish.yml`)
Automatically builds and deploys your website to GitHub Pages when you push to the main branch.
### Link Checker Workflow (`check-links.yml`)
Automatically checks that all URLs in your website are reachable:
- **Runs on**: Push to main, pull requests, weekly schedule (Mondays at 9:00 UTC), and manual trigger
- **Checks**: All links in `.qmd`, `.md`, and `.html` files
- **Reports**: Workflow fails if broken links are detected. Check the workflow logs for details on which links are broken.
- **Configuration**: Customize behavior in `lychee.toml`
- **Manual override**: Add the `links checked by hand` label to a PR to skip the automated link check
To manually trigger the link checker:
1. Go to the Actions tab in your repository
2. Select "Check Links" workflow
3. Click "Run workflow"
## Writing Content
Quarto uses markdown with extensions. Here are some quick tips:
### Headings
```markdown
# Chapter Title
## Section
### Subsection
```
### Code blocks
````markdown
```python
print("Hello, World!")
```
````
### Math equations
```markdown
Inline: $E = mc^2$
Display:
$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$
```
### Citations
Reference a citation: `@citationkey`
### Cross-references
Reference figures, tables, and sections using labels:
```markdown
See @fig-example for details.
```
For more details, see the [Quarto documentation](https://quarto.org/docs/guide/).
## Customization
### Changing themes
Edit the `format.html.theme` section in `_quarto-website.yml`:
```yaml
format:
html:
theme:
light: cosmo # Try: cosmo, flatly, litera, minty, etc.
dark: darkly # Try: darkly, cyborg, slate, superhero, etc.
```
### Adding pages
1. Create a new `.qmd` file (e.g., `chapters/chapter3.qmd`)
2. Add it to the navigation menu and to the sidebar in `_quarto-website.yml`:
```yaml
website:
navbar:
left:
- text: "Chapters"
menu:
- text: "Chapter 1: Introduction"
href: chapters/chapter1.qmd
- text: "Chapter 2: Advanced Topics"
href: chapters/chapter2.qmd
- text: "Chapter 3: Your New Chapter"
href: chapters/chapter3.qmd
sidebar:
contents:
- section: "Chapters"
contents:
- chapters/chapter1.qmd
- chapters/chapter2.qmd
- chapters/chapter3.qmd
```
### Page navigation
`website.page-navigation: true` adds previous and next links at the foot of each page.
Quarto builds those links from the sidebar, not the navbar
([Quarto docs](https://quarto.org/docs/websites/website-navigation.html#page-navigation)),
so the template defines a docked sidebar in the same order as the navbar.
Keep the two in sync: the sidebar order is the reading order.
The sidebar starts with Home, so the previous/next chain starts at the home page.
Quarto highlights the first navbar link whose target appears anywhere in the sidebar,
so a Home entry in the sidebar would highlight "Home" in the navbar on every page.
`page-navigation.html`, included under `format.html` with `include-after-body`,
corrects the highlighting:
it highlights the navbar link (or dropdown) for the current page.
It also adds floating previous/next arrows in the page margins.
The arrows sit in the space beside the page text and are hidden on narrow screens and in print.
### Custom CSS
Add your custom styles to `styles.css`. These will override the default theme styles.
## License
This template is released under the [CC0 1.0 Universal License](LICENSE), which means you can freely use, modify, and distribute it without any restrictions.
## Acknowledgments
This template is based on the structure of the [UCD-SERG Lab Manual](https://github.com/UCD-SERG/lab-manual), which was adapted from the [Benjamin-Chung Lab Manual](https://jadebc.github.io/lab-manual/index.html).
## Support
- [Quarto Documentation](https://quarto.org/docs/guide/)
- [Quarto Community](https://github.com/quarto-dev/quarto-cli/discussions)
- [GitHub Pages Documentation](https://docs.github.com/en/pages)
## Contributing
Feel free to open issues or submit pull requests to improve this template!