/
publishing.qmd
105 lines (70 loc) · 3.88 KB
/
publishing.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
---
title: "Publishing"
format:
html:
toc: true
vignette: >
%\VignetteIndexEntry{Publishing}
%\VignetteEngine{quarto::html}
%\VignetteEncoding{UTF-8}
---
## Overview
The **quarto** package includes several functions that enable you to publish static and interactive documents, websites, and books to [Posit Connect](https://posit.co/products/enterprise/connect/) and [shinyapps.io](https://www.shinyapps.io/). When publishing to Posit Connect, both simple content publishing (local rendering) as well as code publishing (rendering on Connect) are supported.
## Accounts
Before publishing to Posit Connect or shinyapps.io you should ensure that you have an account configured for publishing.
For Posit Connect, use the `rsconnect::connectUser()` function for the server you are publishing to. For example:
```r
rsconnect::connectUser(server = "rsc.example.com")
```
You'll be prompted to authoring your account in a web browser.
For shinyapps.io, use the `rsconnect::setAccountInfo()` function. For example:
```r
rsconnect::setAccountInfo(name = 'norahjones', token = 'AB6783FD23', secret = '36x+k0bBy6W')
```
Note that you can copy and paste this code from the [Tokens](https://www.shinyapps.io/admin/#/tokens) page of your shinyapps.io admin panel.
## Documents
Use the `quarto_publish_doc()` function to publish a single document to Posit Connect. Note that the very _first time_ that you publish you should specify both the `server` and `account` that you want to use for publishing. For example:
```r
library(quarto)
quarto_publish_doc("document.qmd", server = "rsc.example.com", account = "njones")
```
Subsequent updates to the same document don't need to specify the `server` and `account`:
```r
quarto_publish_doc("document.qmd")
```
The example above renders content locally and publishes just the content to the server. You can also render on the server (uploading the source code required to render). You might want to do this in order to create scheduled versions of a report that update automatically when the underlying data changes. To do this, add the `render = "server"` argument:
```r
quarto_publish_doc("document.qmd",
server = "rsc.example.com", account = "njones",
render = "server")
```
## Websites
Use the `quarto_publish_site()` function to publish a [website](https://quarto.org/docs/websites/) or [book](https://quarto.org/docs/books/) to Posit Connect. Note that the very _first time_ that you publish you should specify both the `server` and `account` that you want to use for publishing. For example:
```r
library(quarto)
quarto_publish_site(server = "rsc.example.com", account = "njones")
```
Subsequent updates to the same site don't need to specify the `server` and `account`:
```r
quarto_publish_site()
```
The example above renders content locally and publishes just the content to the server. You can also render on the server (uploading the source code required to render). You might want to do this in order to create scheduled versions of a website that update automatically when the underlying data changes. To do this, add the `render = "server"` argument:
```r
quarto_publish_site(server = "rsc.example.com", account = "njones",
render = "server")
```
## Interactive Docs
You can publish Shiny [interactive documents](https://quarto.org/docs/interactive/shiny/) to either Posit Connect or shinyapps.io.
To publish to Posit Connect, specify both the `server` and `account` that you want to use for publishing (this is required for the first publish only). For example:
```r
library(quarto)
quarto_publish_app("shiny.qmd", server = "rsc.example.com", account = "njones")
```
To publish to shinyapps.io, use `server = "shinyapps.io"`:
```r
quarto_publish_app("shiny.qmd", server = "shinyapps.io")
```
For both services, subsequent publishes need not provide the `server` or `account`:
```r
quarto_publish_app("shiny.qmd")
```