# Installation

## Installation Guide

Follow these steps to set up and start using the theme.

### **Prerequisites**

Before you begin, ensure your system meets the following requirements.

<Aside type="tip">
  If you're on **macOS**, the easiest way to install dependencies is using
  [Homebrew](https://docs.brew.sh/Installation). Homebrew is a package manager
  that simplifies installing software. Follow [this
  guide](https://mac.install.guide/homebrew/index.html) to install Homebrew.
</Aside>

### Install Node.js

Node.js lets you run JavaScript code on your computer. The version you need depends on your edition:

| Edition | Node.js version                                                                       |
| ------- | ------------------------------------------------------------------------------------- |
| Astro   | 22.12.0 or later                                                                      |
| Tina    | 22 (22.12.0 or later) or 24. Tina's command line tool supports only those two versions |
| Sanity  | 22.23.4 or later                                                                      |

Here's how to install it based on your operating system:

<Tabs>
  <TabItem label="Windows">

    Follow these steps to install Node.js on Windows:

    1. Download the latest **LTS version** of Node.js from the official website: [Node.js Downloads](https://nodejs.org/en/download/)
    2. Run the installer after it's downloaded, and follow the on-screen instructions. The installer will guide you through the process.
    3. After installation, open the **Command Prompt** (search for "cmd" in the Start menu) and verify the installation by typing the following command and pressing Enter:

    ```bash
    node -v
    ```

    If Node.js was installed correctly, you'll see the version number (e.g., v22.13.1). This confirms that Node.js is ready to use!

    <Aside type="tip">
      If you run into any issues, you can use **Chocolatey** (a Windows package manager) to install Node.js. Open the **Command Prompt** and run:

      ```bash
      choco install nodejs-lts
      ```
    </Aside>

  </TabItem>

  <TabItem label="macOS">

    Here's how to install Node.js on macOS:

    1. First, make sure you have [Homebrew](https://brew.sh/) installed. Homebrew is a tool that makes installing software easy. If you don't have it, follow [this guide](https://mac.install.guide/homebrew/index.html) to install it.
    2. Open your **Terminal** (you can find it in Applications > Utilities) and run this command to install Node.js:

    ```bash
    brew install node
    ```

    3. After installation, verify Node.js by typing the following command:

    ```bash
    node -v
    ```

    If everything is set up, the terminal will display the installed version of Node.js. Check it against the table above. For the Tina edition, Homebrew may give you a newer version than 24, so use the installer below if it does.

    <Aside type="tip">
      If you prefer, you can also download the installer directly from the official [Node.js Downloads](https://nodejs.org/en/download/) page instead of using Homebrew.
    </Aside>

  </TabItem>

  <TabItem label="Linux">

    To install Node.js on Linux, follow these steps:

    1. Open your **Terminal** and update your package list:

    ```bash
    sudo apt update
    ```

    2. Install Node.js using your package manager:

    ```bash
    sudo apt install nodejs
    ```

    3. Optionally, install npm (Node.js package manager) by running:

    ```bash
    sudo apt install npm
    ```

    4. Verify the installation by typing:

    ```bash
    node -v
    ```

    The installed version of Node.js will be displayed if everything worked correctly. Your package manager may give you an older version than the table above asks for. If it does, use the official guide below.

    <Aside type="tip">
      For other Linux distributions, check the [official Node.js installation guide](https://nodejs.org/en/download/package-manager/) for additional instructions.
    </Aside>

  </TabItem>
</Tabs>

💡 **Need help?** Check out the official [Node.js installation guide](https://nodejs.org/en/download).

---

### **Setting Up Finzo**

Once Node.js is installed, follow these steps to set up Finzo. The theme uses **npm**, which comes with Node.js.

#### Install Dependencies

Navigate to your **project directory** (the main theme folder) and run:

```bash
npm ci
```

This installs the exact dependency versions from `package-lock.json`.

#### Start the Development Server

To start the local development server and view your site on your computer, run:

```bash
npm run dev
```

🔹 Your site will be available at **http://localhost:4321**.

What happens next depends on your edition:

- **Astro:** edit the files in your code editor.
- **Tina:** open **http://localhost:4321/admin/** and click **Enter Edit Mode**. You need no account and no password. See [Tina](../../features/tina/).
- **Sanity:** the site runs with the bundled demo content, with no account. To edit it, run `npm run setup` to connect your own Sanity project, then `npm run dev:all`, and open the Studio at **http://localhost:3333**. See [Sanity](../../features/sanity/).

<Aside type="note">
  `npm run dev` starts the `config.toml` watcher and the site together. We have
  not tested it on Windows. If the site doesn't start there, press
  <kbd>Ctrl</kbd> + <kbd>C</kbd> and run the two parts in two terminals: `npm run toml:watch -- --watch`
  in the first, `npx astro dev` in the second.
</Aside>

#### Create a Production Build

To generate an optimized production build (ready to publish) of your site, run the following command in your project root:

```bash
npm run build
```

This will compile your project, optimize assets, and prepare everything for deployment. The output will be located in the `dist/` folder.

#### Preview the Production Build

To see how your site will look in the final production version, run:

```bash
npm run preview
```

This builds the site and serves `dist/` on your computer, so you can check it before it goes live.

## Available Scripts

This guide covers the npm scripts available in Finzo. Run each one as `npm run <script>`. These scripts help you develop, build, and manage your site efficiently.

---

### **Development Scripts**

#### `dev`

Starts the development server and watches `src/config/config.toml` for changes. Your site will be available at **http://localhost:4321**. In the Tina edition it also starts the editor at `/admin/`.

#### `toml:watch`

Turns `src/config/config.toml` into the settings file the theme reads. Run on its own, it does this once. With `npm run toml:watch -- --watch`, it keeps doing it whenever the file changes.

<Aside type="note">
  `dev`, `build`, `preview`, `astro-check`, and `test` run this step for you, so
  you usually don't need to run it yourself.
</Aside>

---

### **Build Scripts**

#### `build`

Creates an optimized production build of your site. It generates the settings file, builds the site into `dist/`, and removes draft pages from the sitemap.

#### `preview`

Runs the complete build, then starts a local preview server, so you can test the production build before deployment.

#### `deploy:cf`

Runs `wrangler pages deploy`, to upload a build to Cloudflare Pages. Wrangler isn't one of the theme's dependencies, so install it first if you use this.

---

### **Quality Assurance Scripts**

#### `astro-check`

Runs type checking and diagnostics on your Astro project. Run it after you change code or content schemas.

#### `format`

Formats all files in the `./src` directory using Prettier.

#### `test`

Runs the unit tests once with Jest. Run `npm test` for short.

#### `test:watch`

Runs the unit tests and re-runs them when a file changes.

---

### **Utility Scripts**

#### `generate-favicons`

Generates favicon files from your source image. See [Site Identity & Logo](../../customization/site-identify-logo/).

<Aside type="tip">
  Run this script after updating your site's logo or branding to ensure all
  favicon files are regenerated.
</Aside>

#### `generate-multilingual-content`

Adds a language to your site. It needs the language's details, and the flags differ by edition. See [Internationalization](../../customization/internationalization/).

#### `remove-multilingual`

Removes every language except your default one. Useful when moving to a single-language site. See [Internationalization](../../customization/internationalization/) first.

<Aside type="caution">
  In the Astro and Tina editions, this script deletes the other languages'
  files. Make sure to save a git commit or a copy of the folder before running
  it.
</Aside>

#### `remove-draft-from-sitemap`

Removes draft pages from the generated sitemap, so only published content appears in search engines.

<Aside type="note">
  This script is automatically run during the `build` and `preview` commands, so
  you typically don't need to run it manually.
</Aside>

---

### **Scripts Only In The Tina Edition**

| Script          | What it does                                                                             |
| --------------- | ---------------------------------------------------------------------------------------- |
| `tina:generate` | Rebuilds the editor's forms. Run it after you add a section, a field, or a language      |
| `tina:audit`    | Tells you if a save in the editor would lose anything. Run it after you edit files by hand |
| `setup:tina`    | Walks you through online editing with your own Tina Cloud project. It's optional         |

---

### **Scripts Only In The Sanity Edition**

| Script            | What it does                                                                 |
| ----------------- | ---------------------------------------------------------------------------- |
| `setup`           | Logs you in, creates your project, writes `.env`, and uploads the demo content |
| `dev:all`         | Starts the website and the Studio together                                   |
| `studio`          | Starts the Studio on its own. It needs a connected project                   |
| `import-seed`     | Uploads the demo content again. It replaces documents with the same IDs. Add `-- --missing` to keep the documents you already have |
| `sanity:validate` | Checks the Studio's schema                                                   |
| `studio:build`    | Builds the Studio                                                            |
| `studio:deploy`   | Puts the Studio online                                                       |
| `build:preview`   | Builds the preview server for draft preview online                           |
| `start:preview`   | Starts the preview server                                                    |

---

🚀 **You're all set!** Now you can start customizing Finzo to fit your needs. 🎨