# Publishing IPNS names
IPNS names can be published programmatically.
# Publishing IPNS names with Kubo
Start your IPFS daemon, if it isn't already running:
ipfs daemonOpen another command line window and create the file that you want to set up with IPNS. For the tutorial, we're just going to create a simple hello world file:
echo "Hello IPFS" > hello.txtAdd your file to IPFS:
ipfs add --cid-version 1 hello.txt > added bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 hello.txt > 11 B / 11 B [=====================================================] 100.00%Take note of the CID output by IPFS.
Use
catand the CID you just got from IPFS to view the file again:ipfs cat bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 > Hello IPFSPublish your CID to IPNS:
ipfs name publish /ipfs/bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 > Published to k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l: /ipfs/bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244k51...is the public key or IPNS name of the IPFS you are running. You can now change the file repeatedly, and, even though the CID changes when you change the file, you can continue to access it with this key.You can view your file by going to
https://ipfs.io/ipns/k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l:curl https://ipfs.io/ipns/k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l > Hello IPFSMake a change to your file, add it to IPFS, and update your IPNS:
echo "Hello again IPFS" > hello.txt ipfs add hello.txt > added bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq hello.txt > 17 B / 17 B [=====================================================] 100.00% ipfs name publish bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq > Published to k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l: /ipfs/bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq
Note: By default, the
ipns name publishcommand will use theselfkey. You can generate additional keys with theipfs key gen new-keycommand and pass the key name to the publish command using the--keyflag, e.g.ipfs name publish --key new-key bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq.
You can now go back to
https://ipfs.io/ipns/k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6lto view your updated file using the same address:curl https://ipfs.io/ipns/k51qzi5uqu5dgy6fu9073kabgj2nuq3qyo4f2rcnn4380z6n8i4v2lvo8dln6l > Hello again IPFS
You can view the CID of the file associated with your k5 key by using name resolve:
ipfs name resolve
> /ipfs/bafkreidbbor7mvra2xzzl4kmr2sxrtkzaxlzs6rsr5ktgmbtousuzrhlxq
To use a different k5 key, first create one using key gen test, and use the --key flag when calling name publish:
ipfs key gen SecondKey
> k51qzi5uqu5dh5kbbff1ucw3ksphpy3vxx4en4dbtfh90pvw4mzd8nfm5r5fnl
ipfs name publish --key=SecondKey /ipfs/bafybeicklkqcnlvtiscr2hzkubjwnwjinvskffn4xorqeduft3wq7vm5u4
> Published to k51qzi5uqu5dh5kbbff1ucw3ksphpy3vxx4en4dbtfh90pvw4mzd8nfm5r5fnl: /ipfs/bafybeicklkqcnlvtiscr2hzkubjwnwjinvskffn4xorqeduft3wq7vm5u4
# Publishing IPNS names with helia-ipns
Learn more about using IPNS with JavaScript with the helia-ipns (opens new window) package.
# Publishing IPNS names with IPNS Inspector
IPNS Inspector (opens new window) is a web based tool for publishing and resolving IPNS names. To publish an resolve IPNS names, it relies on the delegated routing API, and the public utilities endpoint at https://delegated-ipfs.dev/routing/v1.