Publish a Quarto document with Python to Connect Cloud

Publish a Quarto document with Python to Connect Cloud from GitHub, Positron or VS Code, or the command line. Compare the methods and follow the steps.

Skip the guide and publish the sample document

Publish the example Quarto document to Connect Cloud

In this guide, you publish a Quarto document that uses Python to Connect Cloud and get a URL you can share. You can publish from GitHub, from Positron or VS Code, or from the command line. The sample document is a dashboard of development indicators by continent, with an animated scatter plot and two charts.

A Quarto dashboard with a scatter plot of income per person and life expectancy above area and line charts of population and life expectancy

The sample Quarto dashboard previewed locally

The source code is available in the examples-quarto-python repository.

Getting started

Whichever method you choose, you need the following:

  • A Connect Cloud account.

  • A Quarto document that uses Python. This guide uses the sample document, which has a main file (Connect Cloud calls it the primary file) named dashboard.qmd.

  • A requirements.txt file that lists the Python packages you use, in the same folder as dashboard.qmd. The sample document needs the following packages:

    requirements.txt
    plotly
    jupyter
    pandas
  • Quarto installed, to preview the document on your computer.

Save this file as dashboard.qmd.

dashboard.qmd
---
title: "Development Indicators by Continent"
author: "Gapminder Analytics Group"
format: dashboard
---

```{python}
import plotly.express as px
df = px.data.gapminder()
```

## Row {height=60%}

```{python}
#| title: GDP and Life Expectancy
px.scatter(
  df, x="gdpPercap", y="lifeExp",
  animation_frame="year", animation_group="country",
  size="pop", color="continent", hover_name="country",
  facet_col="continent", log_x=True, size_max=45,
  range_x=[100,100000], range_y=[25,90]
)
```

## Row {height=40%}

```{python}
#| title: Population
px.area(
  df, x="year", y="pop",
  color="continent", line_group="country"
)
```

```{python}
#| title: Life Expectancy
px.line(
  df, x="year", y="lifeExp",
  color="continent", line_group="country"
)
```

To preview the document before you publish, install the dependencies and run Quarto from the folder that contains dashboard.qmd:

Terminal
pip install -r requirements.txt
quarto preview dashboard.qmd
Note

You can also publish a Quarto project by using its _quarto.yml file as the primary file, or a document you already rendered (for example, report.html). See Quarto.

Choose a deployment method

Method When to use it Jump to
GitHub Your code is on GitHub and you want it to update when you push (public repositories only on free accounts) Deploy from GitHub
Posit Publisher You work in Positron or VS Code and do not use GitHub Deploy from Positron or VS Code
Quarto CLI You want to publish from a terminal with quarto publish Deploy from the command line

For more on how these methods differ, see Publishing.

Deploy from GitHub

Use this method when your document’s code is in a GitHub repository and you want changes you push to publish automatically. On a free account, your repository must be public, so anyone can see your code.

  1. Commit dashboard.qmd and requirements.txt, then push your document to a GitHub repository.
  2. Sign in to Connect Cloud.
  3. Click Publish at the top of your Home page. If this is your first time publishing, Connect Cloud prompts you to install the GitHub App, which lets Connect Cloud read your repository.
  4. Select Quarto.
  5. Select your repository.
  6. Check that Branch is the branch that has your content, usually main.
  7. Select dashboard.qmd as the Primary file.
  8. Leave Automatically publish on push on if you want Connect Cloud to update what you published each time you push to this branch. Turn it off to update only when you choose.
  9. Click Publish.
  • Result: Connect Cloud shows a log of the install steps while it deploys. When it finishes, your document is live at an address like https://[content-id].share.connect.posit.cloud, where [content-id] is a unique identifier that Connect Cloud picks. You can set a custom name to change the URL.
  • Update or redeploy: Commit and push to the connected branch and Connect Cloud republishes automatically. If you turned off automatic publishing, click Republish on the content’s card on your Home page. See Republishing.

For all options, see Publish from GitHub.

Deploy from Positron or VS Code

Use this method when you work in Positron or VS Code and want to publish your document directly. Positron includes the Posit Publisher extension. In VS Code, install it from the marketplace first.

  1. Open your project folder in Positron, or in VS Code with Posit Publisher installed.
  2. Click the Posit Publisher icon in the Activity Bar.
  3. Next to CREDENTIALS, click + and select Posit Connect Cloud. A credential is a saved connection to your Connect Cloud account. Your browser opens.
  4. In your browser, check that the Authorize Access code matches the code in Positron or VS Code. Then click Continue and Authorize.
  5. Return to Positron or VS Code and accept or change the name for this credential. Do this once.
  6. Click the + next to Deployments. If Posit Publisher asks which file to publish, select dashboard.qmd.
  7. Enter a title for your content, then select the credential you just added.
  8. Under PROJECT FILES, check that the list includes dashboard.qmd and requirements.txt. Connect Cloud uploads only the files in this list.
  9. Click Deploy Your Project.
  • Result: A success message appears in the lower right of Positron or VS Code. Click View Content in the extension to open the document on Connect Cloud. Its address has the form https://[content-id].share.connect.posit.cloud, where [content-id] is unique to your document.
  • Update or redeploy: Save your changes, open Posit Publisher, select the previous deployment, and click Deploy Your Project again. Keep the .posit folder in your project. It remembers which Connect Cloud content this project publishes to, so the next deploy updates the same content instead of creating a new one.

For the configuration file, multiple deployments per project, and troubleshooting, see Publish from your IDE.

Deploy from the command line

Use this method to publish from a terminal with the Quarto CLI. It requires Quarto version 1.9 or higher.

  1. From your project folder, run this command with the name of your document:

    Terminal
    quarto publish dashboard.qmd
  2. Select Posit Connect Cloud from the list of providers.

  3. When your browser opens, sign in to your Posit account and authorize access. Do this the first time only.

  • Result: Quarto renders your content and deploys it to Connect Cloud. It records the content identifier and URL in a _publish.yml file in your project. The file does not store credentials, so you can check it into version control.
  • Update or redeploy: Run quarto publish dashboard.qmd again. Quarto uses _publish.yml to update the same content.

For more information, see Publish from your console or terminal and the Quarto publishing documentation.

After you deploy

Common things to set up next. They work the same however you deployed your document:

  • Passwords and API keys: Store them as secret variables, not in your code. Add them under Variables in content settings, or during publishing. Read them with os.getenv("NAME").
  • Access and sharing: Control who can view your document in Sharing.
  • Scheduling: On paid plans, schedule your document to republish at set times, for example, to refresh data each day.
  • Custom name and domain: Change the document’s URL with a custom name or a custom domain.
  • Upload size limit: The upload size limit applies when you upload your project files from your editor or the command line.

Troubleshooting

  • Missing package error: Add the package to requirements.txt and republish. Include every package your code cells import, plus jupyter. Make sure the file is in the same directory as dashboard.qmd.
  • Repository not listed: Confirm that the GitHub App has access to it.
  • Document renders locally but not on Connect Cloud: Check that every file the document reads is committed or included in the upload, and that requirements.txt matches the packages you use locally.

If your deployment still fails, read the log that Connect Cloud shows while it deploys and look for the first error. You can also try Error Assist, which gives guidance based on your log output.

Next steps