-
Notifications
You must be signed in to change notification settings - Fork 2
/
04-navigation.qmd
637 lines (461 loc) · 13.7 KB
/
04-navigation.qmd
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
---
format:
revealjs:
theme: [default, slide-styles.scss]
width: 1280
height: 720
include-after-body:
- "all-the-js-code.html"
echo: false
code-line-numbers: false
---
## Before we proceed...
If you've published your site:
Add your `site-url` to `_quarto.yml`, e.g.
```{.yaml filename="_quarto.yml"}
website:
site-url: https://charlotte.quarto.pub/template-site
```
# Let's Add a Page!
::::: columns
::: column
- Create a new page: `/talks.qmd`
- Add some content
- Preview:
`< site url >/talks.html`
:::
::: column
``` {.markdown shortcodes="false" filename="talks.qmd"}
---
title: Talks
---
{{< lipsum 1 >}}
{{< placeholder 400 400 >}}
```
:::
:::::
## Adding Pages
Two decisions:
1. **Structure** Where will it live in your website project?
2. **Navigation** How will people discover it on your website?
# Structure
## File path becomes URL path {.smaller}
::::: columns
::: {.column width="40%"}
File location
`talks.qmd`
`reports/air-quality.qmd`
:::
::: {.column width="60%"}
URL
`{ site url }/talks.html`
`{ site url }/reports/air-quality.html`
:::
:::::
## `index.html` is special {.smaller}
::::: columns
::: {.column width="40%"}
File location
`index.qmd`
`talks/index.qmd`
:::
::: {.column width="60%"}
URL
`{ site url }`
`{ site url }/talks`
:::
:::::
`index.qmd` (or `.md`, or `.ipynb`) -\> `index.html`
`index.html` acts like a default page for the site or directory.
## You aren't limited to `.html` {.smaller}
::::: columns
::: {.column width="40%"}
File location
`data/monthly.csv`
`cv.pdf`
`reports/air-quality.qmd` with `format: pdf`
:::
::: {.column width="60%"}
URL
`{ site url }/data/monthly.csv`
`{ site url }/cv.pdf`
`{ site url }/reports/air-quality.pdf`
:::
:::::
## Structure helps ...
- **You**: Navigate and organize your content
- **Your readers**: Understand context of content from its URL
## Your Turn
Add a new page to your site:
1. Think about the URL first
2. Create the page file in the appropriate location
3. Add some content
{{< countdown 5:00 >}}
# Navigation
## In-text Links
::::: {.columns .fragment}
::: column
Use relative paths
Use `.qmd` rather than `.html`
:::
::: column
``` {.markdown filename="index.qmd"}
I occasionally give [talks](talks.qmd).
You might like to look at
my projects [projects](projects/)
```
:::
:::::
\
::::: {.columns .fragment}
::: column
Use `/` to refer to site root
:::
::: column
``` {.markdown filename="projects/index.qmd"}
You might also be interested
in my [talks](/talks.qmd)
```
:::
:::::
::: footer
https://quarto.org/docs/websites/#linking
:::
## Navigation Bar
In `_quarto.yml` under `website: navbar`
::::: columns
::: column
Give a path from site root
``` {.yaml filename="_quarto.yml"}
website:
navbar:
right:
- talks.qmd
```
:::
::: column
:::
:::::
## Your Turn {.exercise}
Provide links to your new page:
- From somewhere in the content of `index.qmd`
- Before "Home" in the navigation bar
## Navigation Items
::::: columns
::: column
A path:
``` {.yaml filename="_quarto.yml"}
website:
navbar:
right:
- talks.qmd
```
:::
::: column
A nav item object:
``` {.yaml filename="_quarto.yml"}
website:
navbar:
right:
- href: talks.qmd
text: Speaking
icon: megaphone
```
:::
:::::
If you don't have `text`, add `aria-label`
Options for `icon`: [Bootstrap Icons](https://icons.getbootstrap.com)
## Navigation Bar Links
Use navigation items in `left`, `right` and `tools`
::::: columns
::: column
![](images/navigation-navbar-navitems.png)
:::
::: column
``` {.yaml filename="_quarto.yml" code-line-numbers="true"}
website:
navbar:
right:
- talks.qmd
left:
- text: Home
href: index.qmd
icon: house-door-fill
tools:
- icon: github
href: https://github.com/cwickham
```
:::
:::::
::: footer
https://quarto.org/docs/websites/website-navigation.html#top-navigation
:::
## Navigation Bar Options
Other customization: `title`, `logo`, `search`
::::: columns
::: column
![](images/navigation-navbar-options.png)
:::
::: column
``` {.yaml filename="_quarto.yml" code-line-numbers="3-5"}
website:
navbar:
title: cwick.co.nz
logo: logo.png
search: true
right:
- talks.qmd
left:
- text: Home
href: index.qmd
icon: house-door-fill
tools:
- icon: github
href: https://github.com/cwickham
```
:::
:::::
::: footer
https://quarto.org/docs/websites/website-navigation.html#top-navigation
:::
## Your Turn {.exercise}
1. Customize your navigation bar `title`
2. Experiment with the position of your links in the navbar: `left`, `right` or a mix
3. Add at least one item to `tools` in your navbar
{{< countdown 5:00 >}}
# When things get more complicated...
## Your Turn {.exercise .scrollable}
**Brainstorm with your neighbor:** What elements on this page allow the user to navigate the site?
![](images/navigation-quarto-web.png)
...
![](images/navigation-quarto-web-footer.png)
{{< countdown 5:00 >}}
::: footer
<https://quarto.org/docs/websites/website-navigation.html#top-navigation>
:::
## Navigation Elements {.scrollable}
<details>
<summary>Don't peek</summary>
![](images/navigation-quarto-web-annotated.jpg)
...
![](images/navigation-quarto-web-footer-annotated.jpg)
</details>
## Primary Navigation
::::: columns
::: column
Top navigation
![](images/navigation-top.png)
:::
::: column
Side navigation
![](images/navigation-side.png)
:::
:::::
## Primary Navigation
::::: columns
::: column
Top navigation
``` {.yaml filename="_quarto.yml" code-line-numbers=""}
website:
navbar:
left:
- index.qmd
- talks.qmd
- projects/index.qmd
tools:
- text: GitHub
href: http://github.com
icon: github
```
Add items to `left`, `right` and `tools`
:::
::: column
Side navigation
``` {.yaml filename="_quarto.yml" code-line-numbers="|2|3"}
website:
sidebar:
contents:
- index.qmd
- talks.qmd
- projects/index.qmd
tools:
- text: GitHub
href: http://github.com
icon: github
```
Add items to `contents` and `tools`
:::
:::::
## Nested Navigation
::::: columns
::: column
Top navigation
![](images/navigation-top-nested.png)
:::
::: column
Side navigation
![](images/navigation-side-nested.png)
:::
:::::
## Nested Navigation
::::: columns
::: column
Top navigation
``` {.yaml filename="_quarto.yml" code-line-numbers="|5-8"}
website:
navbar:
left:
- index.qmd
- text: Work
menu:
- talks.qmd
- projects/index.qmd
```
Add a `text` item along with `menu`
:::
::: column
Side navigation
``` {.yaml filename="_quarto.yml" code-line-numbers="|5-8"}
website:
sidebar:
contents:
- index.qmd
- section: Work
contents:
- talks.qmd
- projects/index.qmd
```
Add a `section` with its own `contents`
:::
:::::
## Hybrid Navigation
Top navigation navigates between the different "sections" of the website.
Each "section" has its own side navigation.
::::: columns
::: column
![](images/navigation-hybrid-1.png)
:::
::: column
![](images/navigation-hybrid-2.png)
:::
:::::
## Hybrid Navigation
::::: columns
::: column
``` {.yaml filename="_quarto.yml" code-line-numbers="|5,9|6,11"}
website:
navbar:
left:
- index.qmd
- text: Work
href: talks.qmd
sidebar:
- title: Work
contents:
- talks.qmd
- projects/index.qmd
```
:::
::: column
1. Match `navbar` item `text` to a `sidebar` item `title`
2. List `navbar` item `href` as first value in `sidebar` item `contents`
:::
:::::
## Automatic Sidebar
If your structure is good, an automatic sidebar can go a long way:
``` {.yaml filename="_quarto.yml"}
website:
sidebar:
contents: auto
```
## Your Turn {.exercise}
Here's three different navigation options for the same set of content:
- [Automatically generated side navigation](https://charlotte.quarto.pub/navigation-demo-auto-sidebar/)
- [Everything in top navigation](https://charlotte.quarto.pub/navigation-demo-all-top-nav/)
- [Hybrid navigation](https://charlotte.quarto.pub/navigation-demo-hybrid/)
Pick one, and discuss the pros and cons with your neighbor.
*(Done? Expand your conversation to another option or another neighbor)*
{{< countdown 5:00 >}}
## Pro and Cons
+-----------+----------------------------+----------------------------+
| | Pros | Cons |
+===========+============================+============================+
| Side nav | | |
+-----------+----------------------------+----------------------------+
| Top nav | | |
+-----------+----------------------------+----------------------------+
| Hybrid | | |
+-----------+----------------------------+----------------------------+
## Pro and Cons {.hidden}
+----------+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+
| | Pros | Cons |
+==========+=============================================================================+=============================================================================+
| Side nav | - `auto`: easy to generate and maintain | - May show too much detail for sections that aren't of immediate interest |
| | | |
| | - Linearly present linear content (e.g. a progression through a tutorial) | |
| | | |
| | - Can be deeply nested | |
| | | |
| | - Can handle longer entries | |
+----------+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+
| Top nav | - First place most people look | - Not good for long entries, e.g. keep to short single words |
| | | |
| | | - Can't be nested beyond one level |
| | | |
| | | - Nested content is hidden unless clicked on |
+----------+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+
| Hybrid | - Organize lots of content without overwhelming viewer | - Harder to build and maintain |
+----------+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+
# Other navigation elements
*For reference*
## GitHub Links
<https://quarto.org/docs/websites/website-navigation.html#github-links>
``` {.yaml filename="_quarto.yml"}
website:
repo-url: https://github.com/quarto-dev/quarto-web
repo-actions: [edit, issue]
```
## Page Navigation
Navigate between items in a `section` of `sidebar`
<https://quarto.org/docs/websites/website-navigation.html#page-navigation>
``` {.yaml filename="_quarto.yml"}
website:
page-navigation: true
```
## Breadcrumbs
<https://quarto.org/docs/websites/website-navigation.html#breadcrumbs>
Navigate up levels in a nested sidebar. Displayed by default.
``` {.yaml filename="_quarto.yml"}
website:
bread-crumbs: false
```
## Footer
<https://quarto.org/docs/websites/website-navigation.html#page-footer>
``` {.yaml filename="_quarto.yml"}
website:
page-footer:
left: "Copyright 2021, Norah Jones"
right:
- icon: github
href: https://github.com/
- icon: twitter
href: https://twitter.com/
```
## Table of Contents
<https://quarto.org/docs/output-formats/html-basics.html#table-of-contents>
Controlled by `format` not `website`:
``` {.yaml filename="_quarto.yml"}
format:
html:
toc: true
```
# Wrapping Up
## Wrapping Up
- To add content:
1. Add a page/pages in the structure of your site
2. Add a link to the page in navigation
- Listings (*this afternoon*) --- Another navigation option
## Your Turn {.exercise}
Work on your site: add pages, edit navigation, add/edit content.
We are here to help. Publish a new version before lunch.
{{< countdown 10:00 >}}