The example shows how to deploy a simple, static website hosted on ICP. The website is very simple; it just displays the DFINITY logo. While the website in this example is very simple, the method would be the same for a more advanced static website, e.g., based on popular static site generators.
The website consists of an HTML file, a CSS file, and a PNG file:
static-website
├── icp.yaml
└── frontend
├── assets
│ ├── logo.png
│ └── main.css
└── src
└── index.html
The icp.yaml file is a configuration file that specifies the canister used for the dapp. In this case only one canister is needed.
canisters:
- name: frontend
recipe:
type: "@dfinity/asset-canister@v2.1.0"
configuration:
dir: dist
build:
- mkdir -p dist
- cp -r frontend/assets/* dist/
- cp -r frontend/src/* dist/- Install icp-cli:
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
Clone the example project:
git clone https://github.com/dfinity/examples
cd examples/hosting/static-websiteStart the local network:
icp network start -dDeploy the canisters:
icp deployThe URL for the frontend depends on the canister ID. When deployed, the URL will look like this:
http://{canister_id}.localhost:8000
Stop the local network when done:
icp network stop