How I host this website on IPFS

Part 1 - The basics

December 06, 2018IPFS, IPNS

An email came in! Huzzah!!

Omar asks:

“Is relying on IPFS? If the answer is yes, could you say how is it that fast?”

Omar and I had a nice exchange via e-mail and like a true friend he encouraged me to publish my process on the site. Here goes.

This will be a two-part series. Part 1 will cover the basics, and Part 2 will cover Private IPFS networks.

IPFS Website Hosting in General

So, the answer is yes! This site is hosted on IPFS. IPFS is great for hosting static content out of the box, and with tools like OrbitDB, you can work towards creating dynamic, decentralized apps hosted on IPFS.

This guide focuses on the former, and this is accomplished in a few major steps.

  1. Install IPFS and run it locally. I have a guide on IPFS and Docker here.
  2. Create your static content. More on this below
  3. ipfs add /path/to/content This should be wherever your index.html file lives.
  4. You will get a content hash, looking something like QmdGMhGo8qAv9uxhn2gWfMkM57ubfpM386wNz3GqPatT2H

It might take a second, but you should be able to more or less immediately view that content on any public gateway. Here are a few:

Using your own domain name with Your _dnslink DNS entry

We could stop here, but IPFS urls can be ugly. Eventually you’ll want to use your own domain name. This is accomplished via a technique called _dnslink, which require two custom DNS records:

  1. An A record, pointing to the IP address of your domain name, e.g.
  2. A ‘TXTrecord for_dnslink.yourdomain.comwhich contains the content id, like/ipfs/QmdGMhGo8qAv9uxhn2gWfMkM57ubfpM386wNz3GqPatT2H. Note the/ipfs/` prefix.

You can point the A record at, but you don’t control the garbage collection on that ndoe, so you can’t guarantee your content will last longer than 30 days.

IPNS publishing

When you update your content, you will need to change that TXT record every time, since each version of the content will have a different hash. You can avoid this by using IPNS.

I recommend creating a new key for each domain name you want to publish and using those:

$ ipfs key gen --type=rsa --size=4092
$ ipfs name publish QmdGMhGo8qAv9uxhn2gWfMkM57ubfpM386wNz3GqPatT2H

Then, your TXT record for \ might look like /ipns/QmdGMhGo8qAv9uxhn2gWfMkM57ubfpM386wNz3GqPatT2H (not a real IPNS name)

This tends to be slow - as you are publishing out a name and then resolving it via a consensus network of hundreds, maybe even in the thousands, of peers.

If this is all satisfactory, you can stop. But, if you want instant IPNS publication and resolution, and don’t mind a big trade-off, you can try using a private network.

Read more about private IPFS networks in part 2.

TallyLabLike reading about IPFS and want to see it in action? Check out my and @skybondsor's work on TallyLab

Mark Robert Henderson

Mark Robert Henderson lives in coastal Massachusetts and works for the creators of OrbitDB.  The best way to reach him is via e-mail.

This website does not track you.