Build an NFT metadata URI that survives a gateway change
A collection can keep its artwork address even after the minting website closes. The image field can refer directly to a content identifier (CID), leaving the choice of HTTP gateway to the viewer.
Build the image reference before hashing the metadata
Start in a working directory with an artwork folder containing dragon.png. The first command adds the directory. Its CID and the exact filename identify the image. The last command returns a separate CID for the completed metadata file.
images=$(ipfs add -Q -r --cid-version=1 artwork)
jq -n --arg uri "ipfs://$images/dragon.png" '{name:"Dragon",image:$uri}' > dragon.json
ipfs add -Q --cid-version=1 dragon.json
Test what a wallet will fetch
Read the final CID with ipfs cat and inspect image. Resolve the directory CID and path together. A successful fetch of the JSON alone says nothing about whether the linked image is available. Retain both roots: an ipfs:// string inside JSON is an application reference and is not traversed by a normal recursive pin of a UnixFS JSON file.