After reading that Brave has added native IPFS support, I took the plunge and try to host this blog on ipfs. You should be able to reach it using this ipns address.

Fun side story, the first time I heard about the IPFS protocol was by stumbling upon Beaker. It turned out that Beaker’s developed decided to drop IPFS support the week before. I was very confused because all the documentation was still discussing IPFS support while the browser itself did not.

It is straightforward to host a Hugo website on IPFS. First, I changed Hugo’s configuration to use relative links. This requires to set the variable relativeURLs to true in Hugo’s configuration file and drop the baseURL string.

After that, I pushed the repository to the server and rebuilt the website to update the links.

Updating Hash on IPFS

I added these two lines to my post receive hook that I use to build this website:

hash=`ipfs add -r -q /var/www/pacbard.duckdns.org/public/ | tail -1`
curl https://www.duckdns.org/update\?domains\=pacbard\&token\=<DuckDNS token>\&txt\=dnslink\=/ipfs/$hash

These two lines add the latest versions of the website to the IPFS network and update DuckDNS’s TXT to serve this website through dnslink.

Running the IPFS daemon

The last step is to configure the IPFS daemon to run in the background. This will allow you to serve content to peers through the gateways or direct connections.

I created a new user for IPFS with the command sudo adduser --system --group --home /var/lib/ipfs ipfs and set up the following systemd service file:

[Unit]
description=ipfs p2p daemon
After=network.target
Requires=network.target

[Service]
Type=simple
User=ipfs
RestartSec=1
Restart=always
PermissionsStartOnly=true
Nice=18
StateDirectory=/var/lib/ipfs
Environment=IPFS_PATH=/var/lib/ipfs
Environment=HOME=/var/lib/ipfs
LimitNOFILE=8192
Environment=IPFS_FD_MAX=8192
EnvironmentFile=-/etc/sysconfig/ipfs
StandardOutput=journal
WorkingDirectory=/var/lib/ipfs
ExecStart=/usr/local/bin/ipfs daemon --migrate

[Install]
WantedBy=multi-user.target

Everything was up and running after adding my user to the ipfs group.

Update: Actually, I had to open and forward port 4001 to allow my daemon to fully join the IPFS swarm.