Websites on Dfinity

How can we create and host websites on Dfinity?

Right now this is most easily accomplished using webpack. Check out the phone book or superheroes example.

2 Likes

Sorry I’m not a technical person
I think i posted here by mistake
Is there someone could help me build websites on Dfinity?

Are you familiar with HTML/CSS/JavaScript? What exactly do you want to build?

I’m familiar with HTML

Any guide how to host already built react website on dfinity?

This should get you going!

4 Likes

I’m sorry if asking the same questions someone asked before already.
So, I have this folder structure:

dfx.json
public/
  index.html
  style.css

Here is the content of dfx.json

{
“canisters”: {
"www: {
“type”: “assets”,
“source”: [“public”]
}
}
}

When I try to deploy this project on local network (started with “dfx start”), I don’t get any errors on “dfx deploy”

But if I try to access then my HTML page, I get this error from accessing HTTP://127.0.0.1:8000/?canisterId=r7inp-6aaaa-aaaaa-aaabq-cai

An error happened:

_/<@http://127.0.0.1:8000/bootstrap-70b8f66975aa20b1974d.js:2:47697
async*_loadJs@http://127.0.0.1:8000/bootstrap-70b8f66975aa20b1974d.js:2:524975
_main@http://127.0.0.1:8000/bootstrap-70b8f66975aa20b1974d.js:2:525933
async*@http://127.0.0.1:8000/bootstrap-70b8f66975aa20b1974d.js:2:526235
r@http://127.0.0.1:8000/bootstrap-70b8f66975aa20b1974d.js:2:110
@http://127.0.0.1:8000/bootstrap-70b8f66975aa20b1974d.js:2:902
@http://127.0.0.1:8000/bootstrap-70b8f66975aa20b1974d.js:2:913

How can I debug what is wrong here? My HTML page loads without js console errors in the browser.

upd: found this comment What are front end canisters? - #5 by kpeacock, is it still valid?

Replying to my own message, I was using old stable version 0.6.26 of dfx. But with latest 0.7.0-beta.8 everything works as expected

2 Likes

I wish I had read your note earlier. Thank you. My deployment now works as well.

Hi I try the same with

dfx --version
dfx 0.7.0-beta.8

If I try to deploy a simple html page with
dfx deploy --network=ic

I receive the following error??

dfx deploy --network=ic
Creating a wallet canister on the ic network.
The replica returned an HTTP Error: Http Error: status 404 Not Found, content type "text/html", content: <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.19.10</center>
</body>
</html>

What I have missing ?

you can’t deploy to mainnet just yet. try fleek.co if you want to bypass that restriction.

ok I see, I have tried fleek.co and that is working for me. I want try it by myself.

What is the reason why this is not working?

The various subnets are being rolled out in stages, public subnets are next on the list and then deployment will be open to all—it shouldn’t be long now.

1 Like

Is it possible to directly deploy a website to the IC without using Fleek now?

Application subnets have been added now, you can deploy directly.

For static websites, Kyle has written a great article on this here: Static Site Generators on the IC | Kyle Peacock's website

More details on the application subnets: General Availability of Application Subnets