# Best practise for blog publishing

**URL:** <https://discuss.ipfs.tech/t/best-practise-for-blog-publishing/2150>\
**Category:** Ecosystem and Usage\
**Tags:** use-cases-and-apps\
**Created:** [February 23, 2018, 12:44pm UTC](https://discuss.ipfs.tech/t/best-practise-for-blog-publishing/2150 "2018-02-23T12:44:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![singpolyma](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/singpolyma/32/351_2.png) [@singpolyma](https://discuss.ipfs.tech/u/singpolyma)\
**Post date:** [February 23, 2018, 12:44pm UTC](https://discuss.ipfs.tech/t/best-practise-for-blog-publishing/2150/1 "2018-02-23T12:44:50Z")

</div>

If I publish my whole blog as a directory node every time I write a new post, then my posts end up having many different paths/urls because they will be seen as a filename under the directory hash.

However, each post of course has its own hash, and so I can get around this by linking to /ipfs/post-hash instead – then my links never change and the path is always the same.

Question: when hosting on my domain, if I just link to /ipfs/post-hash then to make that work I essentially have to graft a public ipfs gateway onto my domain. Is that a reasonable thing to do? Or should I use [http://ipfs.io/ipfs/post-hash](http://ipfs.io/ipfs/post-hash) links?

---

<div class="post-metadata">

**Author:** ![VictorBjelkholm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/victorbjelkholm/32/10_2.png) [@VictorBjelkholm](https://discuss.ipfs.tech/u/VictorBjelkholm)\
**Post date:** [February 23, 2018, 1:06pm UTC](https://discuss.ipfs.tech/t/best-practise-for-blog-publishing/2150/2 "2018-02-23T13:06:28Z")

</div>

The simple way of setting up a website is to add the entire website to IPFS, then use the root hash.

Quick example:

First create both `index.html` and `firstpost.html` and then add them to IPFS

```auto
$ ls
firstpost.html index.html

$ cat firstpost.html
Hello world

$ cat index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<body>
  <a href="./firstpost.html">First Post</a>
</body>
</html>

$ ipfs add -r .
added QmePw8gVcBMb8x6kAep6aMBAX23hCSk6iZW3i9VKkiFhu1 tmp.YoFFC4RGK0/firstpost.html
added Qmf7mg1Xi1YH7Xeds6J7Dhz8SRvkMRBkP9LTwWSbedwK4h tmp.YoFFC4RGK0/index.html
added QmdKpDPHpNx6cLUWViHXLAzAwnKspYf7iJUMmr8HPcSdBQ tmp.YoFFC4RGK0

```

The root hash is the last hash, `QmdKpDPHpNx6cLUWViHXLAzAwnKspYf7iJUMmr8HPcSdBQ`. This is the one you will send people. Since `firstpost.html` is relatively linked, it’ll work to resolve it when people click on the link.

Now, let’s say we add another post to our example and then add to IPFS again

```auto
$ cat secondpost.html
Second post

$ cat index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<body>
  <a href="./firstpost.html">First Post</a>
  <a href="./secondpost.html">Second Post</a>
</body>
</html>

$ ipfs add -r .
added QmePw8gVcBMb8x6kAep6aMBAX23hCSk6iZW3i9VKkiFhu1 tmp.YoFFC4RGK0/firstpost.html
added QmXsDomV8zSZJ8tSsCiLTdWVV5k8ph3jKdSqfKJhk2P8pW tmp.YoFFC4RGK0/index.html
added QmYQTFLHtocZcbEphEpLbhRd19aj8bpKUR3q5pm2QBJZxR tmp.YoFFC4RGK0/secondpost.html
added QmUeWXkXy6ygANqw4NKnSYf41Mtn35LV6SupgHQdZ89UNt tmp.YoFFC4RGK0

```

When adding the site now, `secondpost.html` is a new file and `index.html` has changed, so the root hash is now instead `QmUeWXkXy6ygANqw4NKnSYf41Mtn35LV6SupgHQdZ89UNt`. This is again the hash you would send people.

But sending everyone the new hash gets boring quickly, so you can use DNS to make people be able to just reload the page instead.

So set `A` records of `example.com` to point to a IPFS gateway (you can use our public gateways if you want, get the IP by pinging `ipfs.io` a couple of times, and set the A records to point to our gateway hosts).

Once you have A records setup, you need to add a `TXT` record as well, to define which hash to add. This TXT record needs to have the value `dnslink=/ipfs/QmUeWXkXy6ygANqw4NKnSYf41Mtn35LV6SupgHQdZ89UNt`. That’s the hash the gateway will load when you load your domain.

Hope this explains how it works. Important point is to keep all links and references to other files relative, so it works both when visiting `ipfs.io/ipfs/$yourHash` and `example.com`.

---

<div class="post-metadata">

**Author:** ![singpolyma](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/singpolyma/32/351_2.png) [@singpolyma](https://discuss.ipfs.tech/u/singpolyma)\
**Post date:** [February 23, 2018, 1:52pm UTC](https://discuss.ipfs.tech/t/best-practise-for-blog-publishing/2150/3 "2018-02-23T13:52:16Z")

</div>

The trouble with this approach is that the absolute path to firstpost keeps “changing” (well, not changing, but we add a new one every time there is a new root hash). So, if I want to give out a link to firstpost on IPFS, the link I should give out constantly changes. But people/systems are going to store the link.

So, I would like to use the unchanging /ipfs/post-hash path as the “permalink” because it’s the one that never changes and people can store forever without it ever pointing to something else.

---

<div class="post-metadata">

**Author:** ![VictorBjelkholm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/victorbjelkholm/32/10_2.png) [@VictorBjelkholm](https://discuss.ipfs.tech/u/VictorBjelkholm)\
**Post date:** [February 23, 2018, 3:26pm UTC](https://discuss.ipfs.tech/t/best-practise-for-blog-publishing/2150/4 "2018-02-23T15:26:33Z")

</div>

Not sure I understand you correctly. If you want to link to a permanent copy of `firstpost.html`, use the hash to it. Which, if you look at the example above, never changes, unless you change the contents of the file itself.

---

<div class="post-metadata">

**Author:** ![godparticle](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/godparticle/32/286_2.png) [@godparticle](https://discuss.ipfs.tech/u/godparticle)\
**Post date:** [October 14, 2018, 10:56pm UTC](https://discuss.ipfs.tech/t/best-practise-for-blog-publishing/2150/5 "2018-10-14T22:56:08Z")

</div>

I did it this way:  
[https://gateway.ipfs.io/ipns/QmZJBQBXX98AuTcoR1HBGdbe5Gph74ZBWSgNemBcqPNv1W/exactly-how-to-host-frog-over-ipfs.html](https://gateway.ipfs.io/ipns/QmZJBQBXX98AuTcoR1HBGdbe5Gph74ZBWSgNemBcqPNv1W/exactly-how-to-host-frog-over-ipfs.html)
