How to add site to IPFS and IPNS

May 11, 2018 · 4 min read

IPFS allows to place p2p content inside web applications and simple web pages. Also you can hosting whole static site in peer to peer(p2p) IPFS network. So other people, who owns IPFS nodes can share your site and be a peer of your content and distribute HTML, CSS, JS and Images from their nodes. After that — if you node stops, the site will live, while someone with an IPFS node will keep a site on his node.

Discover and review best Blockchain softwares

How to get started with your first site in IPFS network:

  1. Run your own IPFS node
  2. Add content to IPFS by simple commands
  3. Use the result content hash(output of command) to get files by link:<your hash here>
  4. You can place this link right in img tag by example: <img src=”<your hash here>”/>
    Or you can publish sites to IPNS and viewable at the link:

Now let’s describe these 4 points in details:

1. Download and run IPFS node:
let’s take a linux amd64 distribution for example:

Then install it following the instructions here:
In my example:

Now you can init and run the node:

2. Add content to IPFS node:

Let’s create your IPFS site directory:

Now, for example you can download some cat image:

And create index.html and style.css with this content:

Finally add the whole site directory to your node:

You should see something like this:

3. Visit your site by IPFS hash

The hash on the last line is the root of your site, you can visit it by opening<your hash here>. So the example site is at

You can get any file by link which you add to IPFS.

4. Publish to IPNS

Despite the fact that you can get a link to the site — when you make changes to it — the link will still point to the previous version of the site. This is because the IPFS is using git-like system for files hashes(hash point to specific version of the file like commit hash). So using this IPFS link you will not be able to get new version of the site.

That’s why we need IPNS — to bind your directory or file to your node peerID. After that — we can get the newest version of site at any time, when using the IPNS link.

Now we want to publish current version of site to IPNS:

You should see something like this:

That will return your peerID (QmYmmfn68vkcFDeZz1NTZyEXTixjjUnUS6UaPdMSsUBWxs) and the hash you are publishing to peerID. You can confirm by running

After that — you can visit published version of site by link:<peerID>

In my example:

In future, when you need to change site content — you can do it, then add new site version to ipfs and publish it again:

New site hash will become attached to your peerId, and when user visit the IPNS link — he will get newest version of site.

But this IPNS link is still too long, and not human-friendly. And that’s why I added bonus point:

5. Bind IPNS to domain

To do that — you need to buy a domain, and then change the domain DNS settings.

You can bind IPNS to domain by adding a DNS TXT record of the form

“dnslink=/ipfs/<peerID>”, so you can have paths like /ipns/
For example, I added my-site to the DNS, and now is available through the url


Please don’t worry if your or my content is loading too slow. An advantage of IPFS is that the more popular the content, the faster it loads. Because more peers shares you content and the client get more sources and your content become faster.

To improve loading speed of your content — ask friends to share your content, i’m using this steps to do so:

If you add my example site and other IPFS sites to your ipfs node — you will help me and all InterPlanetary File System(IPFS) community!


To create multiple sites on your IPFS node — you can generate several named peerId. For example to add new dog site:

Follow me on twitter:


Coinmonks is a non-profit Crypto educational publication.

Sign up for Coinmonks

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.


Written by




Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project —


Written by




Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project —

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store