Introduction
So you read up on IPFS and you’re excited about the technology. Now you want to host your own website on IPFS. How do you start?
Step 1: Gather Tools
- A domain name. The only thing that’ll cost you.
- IPFS Desktop App or CLI.
- Optional: Pinata account to easily ‘pin’ your files.
Step 2: Code
Write some HTML
<!-- index.html -->
<body>
<h1 id="randomNum"></h1>
</body><script>
document.getElementById("randomNum").innerHTML = Math.random();
</script>
This will create a sexy looking website
Step 3: Publish on IPFS
Open up the IPFS desktop then Add+ a file.
Once added, select the file. You should see a ‘Share Link’ button. Don’t be shy. Click it.
The link should look something like:
https://ipfs.io/ipfs/QmZ9M3Fr3GB6eGQFnNZkNZDRETaGb4YF1FGrzGomXHvems
The QmZ9M3F… is your special hash. There’s a security feature built in but that’s for another day. Give it a few min and you should be live!
Step 4: DNS
Sign into your DNS provider. I’m using Namecheap.
Enter this:
Row 1: Notice the “.” after com.
CNAME
@
www.cloudflare-ipfs.com.
Row 2: Replace QmZ9M3Fr3G… with your hash
TXT Record
_dnslink
dnslink=/ipfs/QmZ9M3Fr3GB6eGQFnNZkNZDRETaGb4YF1FGrzGomXHvems
And you’re done!
Side note: Notice we’re using cloudflare? That’s because they act as a gateway. An IPFS gateway is a third party node that gets content for you.
Step 5: Pinata Party (Bonus)
I’m a big fan of Pinata. They make sure your content stays pinned on IPFS so you don’t have to.
Visit: https://pinata.cloud/pinataupload
“Pin By Hash” and enter your hash QmZ9M3Fr3G…
fin.
Credit
Thank you to Juan Benet, IPFS and Protocol Labs team for building the future.
Thank you, Matt Ober and the Pinata team for making the future easy to use.