Publishing

## Overview

The quarto package includes several functions that enable you to publish static and interactive documents, websites, and books to Posit Connect and 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:

    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:

    rsconnect::setAccountInfo(name = 'norahjones', token = 'AB6783FD23', secret = '36x+k0bBy6W')

Note that you can copy and paste this code from the 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:

    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`:

    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:

    quarto_publish_doc("document.qmd",
                       server = "rsc.example.com", account = "njones",
                       render = "server")

## Websites

Use the `quarto_publish_site()` function to publish a website or book 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:

    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`:

    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:

    quarto_publish_site(server = "rsc.example.com", account = "njones",
                        render = "server")

## Interactive Docs

You can publish Shiny interactive documents 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:

    library(quarto)
    quarto_publish_app("shiny.qmd", server = "rsc.example.com", account = "njones")

To publish to shinyapps.io, use `server = "shinyapps.io"`:

    quarto_publish_app("shiny.qmd", server = "shinyapps.io")

For both services, subsequent publishes need not provide the `server` or `account`:

    quarto_publish_app("shiny.qmd")