# Themes with the CLI

Create a theme, develop it against a store, add sample products, publish versions and list it in the Theme Store.

## Create and preview

```bash
tringify theme init my-theme
cd my-theme
tringify theme preview
tringify theme check
```

`theme init` creates a theme from Canvas, the default theme (or from a local theme with `--from`), with its own name, version 1.0.0, a new README and a release workflow for GitHub Actions; nothing is created if it fails validation. `theme preview` serves it with sample content and rebuilds when you save; a failed edit shows the error and keeps the last good page. `theme check` validates it with the rules used on upload.

Edit sections in `src/sections/<name>/` as `body.html`, `style.css` and `schema.json`; `tringify theme build` compiles them into `sections/<name>.vasc`. Keep `src/.generated-sections.json` in version control: it records which compiled files the build generated, so removing a section's source also removes its compiled file, and a compiled file you edited by hand is never deleted.

## Develop against a store

```bash
tringify store create --name "Theme Lab" --country GB --currency GBP
tringify theme dev --store STORE_ID
```

`theme dev` adds the theme to the store as an unpublished theme, then builds and uploads it every time you save, usually in a few seconds, with the same checks as a save in the Store Admin code editor. Refresh the theme preview in Store Admin to see the change; a change that fails prints the error and changes nothing. Each sync is one change in the theme's code history, so it can be seen and undone in Store Admin. The theme it uses is remembered in `.tringify/dev.json`; keep `.tringify/` out of git. `--storefront` chooses another storefront and `--theme` another unpublished theme. A sync into the live theme never reaches shoppers directly: it waits as a change for the merchant to review and publish in Store Admin, so develop on a theme that isn't live.

`tringify theme push` adds a separate copy each time it runs. `tringify theme pull` downloads a store theme, for example one changed in the Store Admin code editor, into a new folder; its sections are compiled `.vasc` files rather than `src/` folders.

## Add sample products

```bash
tringify theme dev --store STORE_ID --with-demo
```

A theme can ship a demo catalog, `demo/catalog.json` with images in `demo/images`, the same one the Theme Store uses for its previews. On a development store, `--with-demo` uploads the images and creates the products with their options, variants and vendors, priced in the store's currency, and turns each demo collection into a tag and a collection for it. Products the store already has are left as they are, so running it again adds only what is missing. The first run asks you to approve product and file access for that store.

## Publish a version

```bash
tringify theme listings
tringify theme diff --listing LISTING_ID
tringify theme publish --listing LISTING_ID --version 1.2.0 --notes "New header layout"
```

Create the listing first, with `tringify theme create` or in the Developer Portal under **Themes**. `theme diff` shows the files that change compared with the newest published version. `theme publish` runs only from a clean git work tree, so every version matches a commit: it shows the same comparison, asks, then packages, uploads, validates and publishes the version and adds the source commit to its release notes. A published version never changes: publish a new version number for every update, and use `tringify theme pull --listing LISTING_ID --version X.Y.Z` to get any published version back exactly.

## List it in the Theme Store

```bash
tringify theme update --listing LISTING_ID --tagline "Bold, image-led layouts" --category CATEGORY
tringify theme submit --listing LISTING_ID
```

Publishing a version doesn't list the theme. Describe the listing with `theme update` (categories come from `tringify theme categories`), publish its documentation with `tringify theme docs`, then send it for review with `theme submit`; an approved listing appears in the Theme Store. See [Theme listing review](/themes/theme-listing-review).

> To publish every version from GitHub Actions when you push a tag, see [Publish from GitHub Actions](/cli/publish-from-github-actions); `theme init` already added the workflow.

