In this tutorial, we show all the steps to deploy an mdbook with the [Hero](https://github.com/freeflowuniverse/crystallib/tree/development/cli/hero) tool.
For this guide, we show an example using the mdbook from the repository [info_tfgrid](https://git.ourworld.tf/tfgrid/info_tfgrid). This setup can be done locally or on a VM. Note that it should be run as root.
We show the steps for a full VM deployed on the TFGrid with WireGuard. We use `10.20.4.2` as a WireGuard IP address. Adjust according to your own setup.
We will be using SSH to connect to the VM and to create an SSH tunnel between the local machine and the VM. This will allow the mdbook output to be displayed on a local browser.
To manage the mdbook files, we will be using the remote explorer feature of either VSCodium or VSCode.
You can use the remote explorer feature of both [VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode.remote-repositories) and [VSCodium](https://open-vsx.org/extension/jeanp413/open-remote-ssh) to manage the mdbook.
- Open the window `Remote Explorer`, click on `Add New` and write the following in the SSH config file:
```
Host 10.20.4.2
HostName 10.20.4.2
User root
```
- Click on `Connect to Host`
- Open the main `/root` directory
- Right-click on the main window of the directory and select `Open in Integrated Terminal`
- The line above will clone the repository `info_tfgrid` at the path `/root/code/git.ourworld.tf/tfgrid`. The same result can be obtained by running the following lines:
For the next steps, you can either run the commands locally (with -p and the proper path) or remotely (with -u and the proper URL). Running the command locally is useful when you are doing changes to the mdbook and you want to test them before pushing the new files to the remote repository.
> Note: In all cases, make sure to replace **bookname** by the name of your book, e.g. test.
To preview the mdbook on a local browser (via the file **index.html**), run the following command and open a browser with the URL **localhost:5173**. Make sure to replace `<book_name>` with the name of the book.
If you get the following error: "cli execution error: Cannot pull repo: /root/code/git.ourworld.tf/tfgrid/info_tfgrid because there are changes in the dir.", you can try the following as a fix: