The `site-builder` is a CLI tool that lets you create, edit, and publish Walrus Sites. You can install it using [`suiup`](https://github.com/MystenLabs/suiup) or a pre-built binary.

- [x] Install a recent version of [Rust](https://www.rust-lang.org/tools/install).

- [x] [Install and configure Walrus](/docs/getting-started).

## Installation

> **Warning**
>
> The stable branch of Walrus Sites is `mainnet`. Before deploying your site to production, make sure you pull the latest `mainnet` changes.
### Using `suiup`

Install the `site-builder` using `suiup`, the recommended tool for managing and switching between different versions of Sui, Walrus, and other ecosystem tools.

First, install `suiup`:

```sh
$ curl -sSfL https://raw.githubusercontent.com/Mystenlabs/suiup/main/install.sh | sh
```

Make sure `$HOME/.local/bin` is in your `PATH` so your terminal can find the `suiup` binary. To check, run:

```sh
$ echo $PATH | tr ":" "\n"
```

Then, install the `site-builder`:

```sh
$ suiup install site-builder@mainnet
```

The `site-builder` will automatically be installed in `$HOME/.local/bin`. Confirm the installation with the command:

```sh
$ site-builder --help
```

### Using a pre-built binary

A `site-builder` client binary is available for Ubuntu, macOS (Apple and Intel CPUs), and [Windows](#windows) operating systems. You can download any of the binaries from the Google Cloud Storage (GCS) bucket using the links in the table below.

| OS      | CPU                   | Architecture |
|---------|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| Ubuntu  | Intel 64bit           | [`site-builder-mainnet-latest-ubuntu-x86_64`](https://storage.googleapis.com/mysten-walrus-binaries/site-builder-mainnet-latest-ubuntu-x86_64)                |
| MacOS   | Apple Silicon         | [`site-builder-mainnet-latest-macos-arm64`](https://storage.googleapis.com/mysten-walrus-binaries/site-builder-mainnet-latest-macos-arm64)                    |
| MacOS   | Intel 64bit           | [`site-builder-mainnet-latest-macos-x86_64`](https://storage.googleapis.com/mysten-walrus-binaries/site-builder-mainnet-latest-macos-x86_64)                  |
| Windows | Intel 64bit           | [`site-builder-mainnet-latest-windows-x86_64.exe`](https://storage.googleapis.com/mysten-walrus-binaries/site-builder-mainnet-latest-windows-x86_64.exe)      |

If you prefer, you can also use a `curl` request to download the latest build from the GCS bucket. Ensure you set the `$SYSTEM` variable to your current system: `ubuntu-x86_64`, `ubuntu-x86_64-generic`, `macos-arm64`, `macos-x86_64`.

```sh
$ curl https://storage.googleapis.com/mysten-walrus-binaries/site-builder-mainnet-latest-$SYSTEM -o site-builder
$ chmod +x site-builder
```

Once you have downloaded the `site-builder` binary, move it to any directory included in your `$PATH` environment variable. Standard locations are `/usr/local/bin/`, `$HOME/bin/`, or `$HOME/.local/bin/`. To view locations in your $PATH variable, run the command:

```sh
$ echo $PATH | tr ":" "\n"
```

Verify you can now run `site-builder` using the following command:

```sh
$ site-builder --help
```

If successful, the console responds:

```sh
Usage: site-builder [OPTIONS] <COMMAND>

Commands:
  deploy   Deploy a new site on Sui
  publish  Publish a new site on Sui
  update   Update an existing site
  convert  Convert an object ID in hex format to the equivalent Base36 format
  sitemap  Show the pages composing the Walrus site at the given object ID
  help     Print this message or the help of the given subcommand(s)

  ⋮
```

### Installing on Windows {#windows}

You can use Windows PowerShell to download the latest build from the GCS bucket. 

```powershell
(New-Object System.Net.WebClient).DownloadFile("https://storage.googleapis.com/mysten-walrus-binaries/site-builder-mainnet-latest-windows-x86_64.exe", "site-builder.exe")
```

Move `site-builder.exe` to a directory in your `PATH`:

```powershell
$env:Path -split ';'
```

You can now run `site-builder` using the following command in PowerShell (note the lack of `.exe` extension):

```powershell
site-builder
```

## Configuration {#configuration}

To use `site-builder` commands to deploy Walrus Sites, the `site-builder` tool must be configured. Configuration is done using the [`sites-config.yaml` configuration file](/docs/sites/getting-started/using-the-site-builder). You can download the `sites-config.yaml` using the following command:

```sh
$ curl https://raw.githubusercontent.com/MystenLabs/walrus-sites/refs/heads/$NETWORK/sites-config.yaml -o ~/.config/walrus/sites-config.yaml
```

> **Info**
>
> Replace `$NETWORK` with either `testnet` or `mainnet` depending on which network you want to deploy your site to. If you plan to test your site on Testnet first, then deploy on Mainnet afterwards, you will need to ensure the `sites-config.yaml` file contains configurations for both networks.
By default, `site-builder` requires the `sites-config.yaml` file to be in one of the following locations: 

- The current working directory you are running `site-builder` commands from. You can print the current working directory to the console with the command `pwd`. 
- `$XDG_CONFIG_HOME/walrus/`
- `~/.config/walrus/`
- `~/.walrus/`

If the configuration file is not in one of these locations, and you do not specify the location of the file with the flag `--config`, you will see the following error when attempting to run any `site-builder` command:

```sh
Error during execution: could not find a valid sites configuration file; consider using  the --config flag to specify the config
```

Specify a different directory by passing the `--config` flag to any `site-builder` command:

```sh
$ site-builder --config /path/to/sites-config.yaml deploy <build-directory-of-a-site>
```