1

Putting My Blog on IPFS

 2 years ago
source link: https://www.gkbrk.com/2017/10/putting-my-blog-on-ipfs/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Hi. It looks like you are running Chrome or a Chromium-based browser.
For the future of the open web, please consider giving Firefox a try.

Putting My Blog on IPFS

Embracing the Decentralized Web
Reading time: about 2 minutes

I’ve always been fascinated by the idea of peer-to-peer network protocols, and putting my website on a distributed network was something I’ve been meaning to do for a while. The recent increase in blog posts about IPFS finally pushed me over the tipping point. Hopefully, you can read this article on IPFS here.

I am really happy with this change, and I urge everyone to do the same with their websites. IPFS may or may not be the perfect solution to the decentralized web, but we need to start somewhere. In this article, I will try to give a step-by-step guide for putting static websites on IPFS.

Getting started

First, a bit about getting your feet wet with IPFS. Every file and directory in IPFS can be referenced by a hash that looks like QmNiMm9LUX9R4Ezu2NAsraxFSyrbNR6rgGwCDu71Dy4NwQ. If you have it installed on your computer, you can go on the command line to download and view files.

ipfs cat QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u

This command will output ‘Hello World’. I chose this as an example, because I assume hello world is something a lot of people will have on their nodes.

Just as easy as getting files, putting files is also easy. Lets say you have a picture of a cat called kitten.jpg. Running ipfs add kitten.jpg give you a hash and your node will start seeding it. You can just give that hash to people you want to share the file with. You can try it like this.

Putting a website on IPFS

So how do we go from putting up a file there to putting up a whole website? Just like most unix commands, IPFS also accepts the parameter -r for running the command recursively. Let’s say our website is in the public/ directory. If we run ipfs add -r public/, it will first add all the files and subdirectories into IPFS, and finally give us a hash that represents the whole folder.

Other people can view your website with that hash. The hash changes if you update your website, but you can solve this issue with IPNS. IPNS basically allows you use a private key to update the contents of your files. As long as you have your private key, you can publish updates to your IPFS website.

If you want to use IPNS (you probably do), you need to run `ipfs name publish

`. After doing these, you can give your IPNS hash to people, and whenever you update your website they will see the updated version as well. But as a person who has keeps losing private keys, I can just use my domain's DNS records to change the hash whenever I need to. ## Using DNS for IPFS If you don't want to deal with giving out long hashes to people, IPFS allows you to use your normal domain as well. To do this, you need to add a line to your DNS records. Just go to your domain's DNS settings, and find where to add a TXT record. In the content, you should write `dnslink=/ipfs/` or `dnslink=/ipns/` depending on what you use. As an example, you can access my blog from [/ipns/gkbrk.com](https://ipfs.io/ipns/gkbrk.com). ## Hugo Specific Fixes When you are hosting your website on IPFS, one issue you should be careful of is _relative_ vs. _absolute_ links. If the linking is wrong, you will have issues when people try to navigate your website. In your Hugo config file _(config.toml)_, you should comment out baseurl and set relativeURLs to true. ```toml # baseurl = '' relativeURLs = true ``` If there are still issues, you can fix them whenever you come across them incrementally. --- After all these steps, you should be able to successfully host your website on IPFS. If you do it, make sure to let me know by sending an email, a tweet or comment on where you're reading this from.

Citation

If you find this work useful, please cite it as:
@article{yaltirakli201710puttingmyblogonipfs,
  title   = "Putting My Blog on IPFS",
  author  = "Yaltirakli, Gokberk",
  journal = "gkbrk.com",
  year    = "2017",
  url     = "https://www.gkbrk.com/2017/10/putting-my-blog-on-ipfs/"
}
Not using BibTeX? Click here for more citation styles.

Comments

Comment

Name

Comment by test
2021-09-23 at 12:26
Spam probability: 0.795%

how to comment

Comment by admin
2019-02-21 at 22:15
Spam probability: 0.0%

Hi Interested User. For the comments on my website, I am using a custom CGI script. I didn't get around to open-sourcing it but it's pretty bare-bones.

Comment by Interested User
2019-02-21 at 16:59
Spam probability: 0.0%

What backend software do you run to collect these comments and process them?

Comment by Something Special
2018-12-18 at 06:39
Spam probability: 0.0%

Like Barefoot Rob said, https://ipfs.io/ipns/gkbrk.com/ loads fine but all the links display errors like such: `ipfs resolve -r /ipns/ipfs.io/2018/06/fetching-activitypub-feeds/: no link named "2018" under QmS4fTD7Rh8NouNhp9uZbawUdBpgHaUTeL3EnxX8Tiiu7H`

Comment by Frank
2018-12-13 at 13:23
Spam probability: 0.0%

You should probably also mention that your website won't be available if your IPFS node isn't running (and if no one else has a cache of your files).

Comment by Barefoot Rob
2018-12-10 at 22:35
Spam probability: 0.0%

https://ipfs.io/ipns/gkbrk.com top page works, but links are not found.

Comment by admin
2018-09-30 at 12:53
Spam probability: 0.0%

Hi Daniel, that might indeed be the issue. I moved hosts recently and I might have migrated the DNS entry incorrectly. It's fixed now and the name should start resolving soon.

Comment by Daniel A.
2018-09-30 at 00:51
Spam probability: 0.0%

"ipfs resolve -r /ipns/gkbrk.com/: could not resolve name"

I believe the issue might be that you've double-quoted the dnslink record in your DNS.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK