You rebuild a static site. You change nothing visible. No new text. No new image. You add the folder to IPFS again. You get a different address.
That feels wrong at first. The site looks the same. The files have the same names. Why should the link change?
It changes because IPFS does not address your site by name or location. It addresses it by content. Every byte of the output matters. If one byte changes anywhere in the graph, the identifier changes too.
This is normal. It is also easy to misunderstand. Once you see how the identifier is built, the rebuild problem becomes easier to plan for.
Your address is your content
Most web links say where to find something. A domain points to a server. A path points to a file on that server. If the file changes, the link can stay the same.
IPFS works the other way. A content identifier, or CID, is a label used to point to material in IPFS. It does not say where the content is stored. It forms an address based on the content itself.
That address is short even when the content is large. CIDs are short, regardless of the size of their underlying content. A large video folder and a small text file both get compact labels you can send around the network.
The rule is simple and strict. Any difference in the content will produce a different CID. The reverse is also part of the promise. The same content added to two different IPFS nodes using the same settings will produce the same CID.
So a rebuild is not judged by how it looks in a browser. It is judged byte by byte. Same bytes with same settings means same CID. Different bytes means different CID.
Hashes make this possible
Under every CID is a cryptographic hash. Cryptographic hashes are functions that take some arbitrary input and return a fixed-length value. The same input always gives the same output for a given algorithm.
IPFS supports several hash algorithms. IPFS uses the sha-256 hashing algorithm by default, but there is support for many other algorithms. SHA-1 is also well known because it is used by git. SHA-256 and BLAKE2 are other examples.
Different algorithms make different length outputs. SHA-1 creates a 160-bit hash, while SHA-256 creates a 256-bit hash. That is why the same input text gives a shorter value in SHA-1 and a longer value in SHA-256.
For example, the input Hello world has a known SHA-1 value and a known SHA-256 value. The values look unrelated even though the input is identical. The algorithm choice controls the output.
Hashes used here have four traits that matter for builders.
- Deterministic. The same input always returns exactly the same output.
- Uncorrelated. A small change should generate a completely different hash.
- Unique. It is infeasible to generate the same hash from two different messages.
- One-way. It is infeasible to guess or calculate the input from its hash.
Those traits are why a hash can stand in for data. A hash is a fixed length, so the SHA-256 hash of a one-gigabyte video file is still only 32 bytes. That small size matters in a distributed system. A computer running IPFS can ask peers if they have a file with a particular hash. If one does, it sends back the whole file.
This is content addressing in one sentence. The content itself is used to form an address, rather than information about the computer and disk location it is stored at.
A CID is not just a file hash
Here is the connection many builders miss. A CID looks like a file hash. It is not.
A normal checksum hashes the file as one flat string of bytes. You download a file, run SHA-256 on it, and compare it with the published value. IPFS does something more layered.
IPFS splits content into blocks and links those blocks in a directed acyclic graph, often called a DAG. Because IPFS splits content into blocks and verifies them through directed acyclic graphs (DAGs), SHA file hashes will not match CIDs.
Each block gets its own hash. The parent links to the hashes of its children. The top of the structure points to everything below it. Change one leaf block and the change ripples upward.
This pattern has a known name. In a hash tree or Merkle tree every leaf node is labelled with the cryptographic hash of a data block, and every non-leaf node is labelled with the cryptographic hash of the labels of its child nodes. That structure allows efficient and secure verification of large data. IPFS is listed among the systems that use this idea, alongside BitTorrent, ZFS, Git, and others.
In a binary hash tree, hash 0 is the result of hashing the concatenation of hash 0-0 and hash 0-1. The root becomes a commitment to all the leaves. You can reveal a leaf and prove it belongs to the commitment without sending the whole tree.
IPFS adds more wrapping on top. A CID contains the hash plus codec information about the block. In general, the CID is made by computing a cryptographic hash of the block data, then combining that hash with codec information using multiformats.
That means three pieces travel with the hash.
- Multihash for information on the algorithm used to hash the data.
- Multicodec for information on how to interpret the hashed data after it has been fetched.
- Multibase for information on how the hashed data is encoded. Multibase is only used in the string representation.
APIs and docs say this clearly. CIDs will not match the hash of the data. While a data block CID is built using the cryptographic hash of the data block, a CID contains additional information that the hash does not.
That extra information is useful. It tells a client how to decode and read the block. It also future proofs hash choice by letting multiple hash functions coexist. But it means you cannot take a normal file checksum and expect it to equal an IPFS CID.
The hidden part: your file is wrapped before it is hashed
There is one more layer that surprises teams. When you add a file, IPFS does not only hash your raw bytes. It formats the file through an abstraction called UnixFS.
Through UnixFS, the file is formatted in a DAG of many chunks of user data. That DAG structure needs its own metadata to organize and transmit the chunks. That metadata is also part of the block data that is hashed and thus affects its CID.
An open IPFS docs issue describes this exact confusion. New users learn the clean theory first. Forget where you store it. All that counts is the data itself, which is identified through its hash. Then they add a file and assume the CID is simply the hash of that file.
The issue notes the gap between those two views. In theory, users picture a single neutral block of their data. In practice, the file is split into chunks and wrapped with IPFS metadata. The same file added with different parameters, or even same parameters but new IPFS versions with different defaults, may be represented by different CIDs.
Put plainly, the CID is not the hash of your file. It is the hash of a processed representation of your file plus supporting data.
This is why rebuilds are so sensitive. A build tool may change a byte inside an asset and keep the page visually identical. It may reorder files in a folder. It may split chunks differently. It may use different import settings. Any of those changes alters the blocks or the wrapping. The result is a new CID.
It is also why two machines can disagree. Same source files with different chunk settings will not match. Same bytes with different codec defaults will not match. The CID reflects both your content and the choices made when that content was prepared.
What this means for a site rebuild
Think of a static build as a folder of outputs. HTML, CSS, JavaScript, images, fonts, source maps, and generated JSON. IPFS chunks each file, hashes each chunk, builds a DAG for the folder, and hashes that too. The folder CID you link to sits at the root.
If one output file changes by one byte, its block hash changes. Its parent DAG node changes. The folder root changes. Your old link still resolves, but it resolves to the old tree. It does not follow the new build.
That uncorrelated property of hashes makes the effect total. A small change should generate a completely different hash. There is no near match. There is no close CID. It either matches or it does not.
This can feel wasteful. You changed a footer date. Now you have a new address for the whole site. But the same property gives you strong versioning. Every build has its own permanent snapshot. Old links keep working as long as someone keeps the old blocks available. New links point to the new snapshot.
Plan for caching, versioning, and stable links
You cannot stop rebuilds from changing CIDs. You can plan around it.
Separate stable entry points from build snapshots
Treat each folder CID as a release. Keep it immutable. Put a stable name in front of it for users. That stable name can be DNS, a name system pointer, or an app level redirect that you update after each verified build.
This keeps history clean. If a deploy breaks, the prior CID is still addressable. You roll back by pointing the stable name to the prior snapshot. Nothing in the old tree has moved.
Make builds as repeatable as you can
Use the same add settings on every machine. Same chunking. Same hash function. Same codec defaults. Same IPFS version where possible. Remember that the same content added with the same settings should give the same CID. Different settings can give a different CID even when your source files are identical.
Log those settings with the release. Note the tool version and flags. Future you will need them to reproduce a CID or to explain why a CID changed.
Reduce needless byte churn
Since any difference produces a different CID, small output differences have large addressing costs. Avoid rewriting files that did not change. Keep output order stable. Be careful with steps that inject build times, random IDs, or absolute paths into assets. If the bytes must differ, accept the new CID. If they do not need to differ, keep them stable so fewer subtrees change.
This also helps caching. When only one file subtree changes, clients that already have the other blocks only need the new blocks plus the new path to the root. Stable bytes mean better reuse across versions.
Link inside the build with care
Relative links inside a folder snapshot keep working because the whole folder moves together. Hard coded links to a prior folder CID will keep pointing to the old snapshot. That is correct behavior for archives, but it can confuse users if they expect latest. Decide which links should freeze a version and which should follow the stable entry point.
A short checklist before you publish
- Confirm what settings you used to add the folder, so the CID can be reproduced.
- Record the root CID as the release ID, not as a mutable tag.
- Update one stable pointer after testing, rather than sharing raw CIDs everywhere.
- Keep old snapshots available while old links still circulate.
- Explain to the team that a new CID does not mean the build broke. It means the bytes or the wrapping changed.
Content addressing trades convenient in place edits for strong identity. You lose the comfort of a fixed path that always shows latest. You gain proof of what exact bytes a link resolves to.
Once you expect every rebuild to mint a new address, the work shifts. You stop fighting the new CID. You start designing a thin stable layer above a stack of permanent snapshots.
