“I believe the role of the government is too big. Society must be more decentralized.” ― Pavel Durov ―

This blog post will discuss how to create a decentralized website/blog.

Generating Content ID (CID)

First, you need to create ipfs CID (content-id) by using IPFS InterPlanetary File System is a peer-to-peer network protocol for storing and sharing data in a distributed file system, with addresses based on content, not location.

There are two ways to do it, either

  1. Through running your own ipfs node
  2. Uploading folder to Pinata cloud (easy way)

Through running your own ipfs node

  1. Install ipfs
    • For mac - brew install ipfs
    • For Ubuntu Linux - snap install ipfs
  2. Initialize ipfs - ipfs init
  3. Run ipfs daemon - ipfs daemon
  4. Go to http://localhost:5001
  5. At this point you can upload your file/folder that contains index.html of your site/blog

Note: You can use website generators like Nikola or Jekyll or Hugo. For Complete list of site generators you can check jamstack.org
This blog was built using Jekyll.

  1. To upload, go to http://localhost:5001 and click on files and click on import and choose file or folder that has index.html


  2. Once uploaded and pined, ipfs CID will be created.



Note: You need to keep your node running for CID to be accessible.
You can use VPS (Virtual Private Server) from Digital Ocean or Linode or Vultr or Amazon Light Sail or home server, to keep ipfs node running

Uploading folder to Pinata cloud

With this approach you don’t need to install ipfs locally
Create account in Pinata Cloud and upload your file or folder that has index.html to pinata cloud and copy the CID, like below



Accessing Content through CID

Now its time to access/share your content through CID

Accessing through gateways

You can share CID with anyone, and they can access it through the below gateways

  1. Through ipfs gateway - use https://ipfs.io/ipfs/<YOUR-CID>/
  2. Through Cloudflare ipfs gateway - use https://cloudflare-ipfs.com/ipfs/<YOUR-CID>/

Accessing through a custom domain

The above step is good, but you won’t be remembering the CID will be difficult, so how about accessing through a custom domain

  1. Buy a domain from Google domains or Namecheap
  2. Best way is to maintain the domain using Cloudflare (it will give SSL for free for your domain). Create a Cloudflare account and add your domain
  3. Go to DNS tab


  4. Add these records in DNS.
    • Add CNAME record for your domain & www and point that to cloudflare-ipfs.com
    • Add TXT record with the name _dnslink.your.website and value dnslink=/ipfs/<YOUR_CID>


Now you should be able to access your site through the custom domain.

Accessing through ENS domain

If you want to go further to access your content through Ethereum blockchain, you can use Ethereum Name Service (ENS)

  1. Register your name on ENS Domains.

Note: You need to have Ethereum Wallet to proceed. You can use Metamask Chrome plugin to purchase Ethereum. This will handle all the Ethereum transactions.

  1. Once you have Metamask installed in Chrome, you can follow the steps to register your name in ENS


  2. Once the above step is done, you can add your ETH/BTC/LTC public address to use this namespace for crypto transactions.
  3. Here you can add your content ipfs://<YOUR-CID>. This will create a https://<NAME>.eth.link. You can use this link to access your content.


Note: Publishing this way is expensive since this requires to pay gas price every time you modify your site.

  1. Anyone with your .eth domain can access your content currently there are few browsers like Brave or Opera that can be used to access .eth domains. If you visit any .eth domain in Brave, you will be given the below message to enable ENS. It might be in the future other browsers will adopt ENS.


Deploying content in multiple nodes

One of the advantage of using IPFS protocol is to avoid single point of failure, you can deploy the same content in multiple nodes. Now you have the CID, you can pin the same CID in multiple nodes

  1. If you have CID from pinata.cloud, you can pin the CID in another node by using command - ipfs pin add <YOUR-CID>
    or through UI


  2. If you have CID through your node, then you can upload to pinata.cloud, like below



Automate publish

You can use IPFS deploy to automate publishing to different IPFS clouds like Infura, Pinata, Fission and also set Cloudfare DNS settings.


Conclusion

Done now, you have your website/blog running using peer-to-peer network protocol IPFS.

I hope this helps.