Framework for Python

Publishing

publish_notebook()

Render a Quarto notebook with the quarto command and upload the result.

A bucket with static_hosting: true gets <dest>/index.html and a clean URL ending in /. Other buckets get <dest>.html as one self-contained file.

With no connection and no buckets in the settings, a project with a Framework Cloud token publishes to the cloud instead.

Usage

publish_notebook(
    file: str | Path,
    dest: str | None = None,
    connection: str | None = None,
    self_contained: bool = True,
    format: str = 'html',
    slug: str | bool | None = None,
    include_private: bool = False,
    *,
    to: str | None = None,
    allow_private: bool | None = None,
    collection: str | int | None = None,
    share_unlisted: bool = False,
) -> str

Arguments

Name Type Default Description
file required str | Path

An existing .qmd or .ipynb file.

dest str | None None

Where to put the result in the bucket, without .html. Default: the file's name without its extension. On Framework Cloud it names the document when slug is not a string.

connection str | None None

A storage bucket name from the settings. Setting it always publishes to a bucket. Default: the project's default bucket, or Framework Cloud when no bucket is configured.

self_contained bool True

Embed resources in one HTML file. Buckets without static hosting are always self-contained. With static hosting, False uploads the render folder.

format str 'html'

The Quarto output format passed to --to. Framework Cloud accepts only "html". Default: "html".

slug str | bool | None None

For Framework Cloud: a string names the document and turns on its readable URL, True uses the derived name, and False turns the readable URL off. A storage bucket ignores it with a warning.

include_private bool False

Upload files with "private" in their path without asking. Only a person who has reviewed the files should set this.

to str | None None

"cloud" explicitly publishes to Framework Cloud and "bucket" selects storage. "github" publishes to the project's GitHub Pages site: the page is copied to published/<slug>/ at the top of the repository, only that folder is committed, and the commit is pushed. Pages sites are public, even from a private repository. Default: a storage bucket or Framework Cloud.

allow_private bool | None None

Deprecated name for include_private.

collection str | int | None None

Existing project collection ID or slug on Framework Cloud.

share_unlisted bool False

Explicitly allow collection readers to access an unlisted artifact.

Value

The public URL.

Raises

  • FrameworkError: When the file is missing or not a notebook, has "private" in its path and is not confirmed, Quarto is not installed, rendering fails, or there is nowhere to publish.