Aller au contenu
Blog

Gemini Canvas rewrites entire code on every edit

Gemini Canvas rewrote your whole page for one small change? Why it happens, how to limit it, and how to make the last edits yourself in the HTML.

The Liite team7 min de lecture

Short answer

Canvas tends to regenerate the whole document on each prompt, and Google hasn't published an official explanation. Select the exact part you want changed, tell Gemini what must stay as is, and copy every good version into your own file. Once the page is close, make the final edits directly in the code.

You asked Gemini Canvas to change one line, and it rewrote the whole page, sometimes breaking parts that worked. People on Reddit and in Google's community forums describe this as Gemini Canvas rewriting the entire code, or Gemini Canvas breaking the website.

Gemini Canvas rewrites entire code

Why it happens

Canvas is a chat model writing into a document. The likely cause is that, when you ask for a change, the model produces a new version of the whole file instead of a small patch. Unrelated parts can drift in the process: a color changes, a function is renamed, a section is shortened. Google hasn't published an explanation we can point to, so treat this as the probable cause, not a confirmed one.

Here are the causes people describe, most common first:

CauseWhat you seeWhat to do
Full regeneration instead of a patchUnrelated sections change or breakSelect the part, state what must not change
Model works from an older copyYour hand edits vanishKeep your own file, re-paste before prompting
Canvas not savingWork missing after a reloadCopy out each good version
Long chat with many roundsQuality drifts with each roundStart a fresh chat from your saved file

The second row needs context. In some threads, people say Canvas on Gemini 3 didn't see the edits they had made by hand in the canvas, or that the canvas didn't save. If the model works from an older copy than the one on your screen, a "rewrite" can also undo your own changes. We can't tell you whether Google has fixed this. Check the Gemini Apps help center and release notes for the current behavior.

Step-by-step fixes

These are workarounds people report, most useful first. None is guaranteed, so check the result every time.

1. Select the part and annotate it

Highlight the section on the canvas and request the change on that selection, instead of describing it in the chat. Threads say this keeps the edit narrower. The exact menu labels can change between Gemini versions, so look for the selection or annotation option in the canvas toolbar.

2. Say what must not change

Ask for one change and state that everything else stays exactly as it is. For example:

Change only the heading in the hero section to "Open Tuesday to Saturday".
Do not change any other text, class names, colors, scripts or layout.
Return the full file.

The model can still ignore this, so don't skip the comparison step below.

3. Upload files instead of pasting

Some people say attaching the file works better than pasting a large block of code into the prompt. It also makes sure the model starts from the version you actually have.

4. Copy every good version out

Before each new prompt, copy the working code into a local file and give it a name like index-v3.html. If the next reply breaks something, you can go back in seconds. This also protects you if the canvas fails to save.

5. Compare before you accept

Paste the old and new versions into a text diff tool, such as our text compare tool, to see exactly what the model touched. If it changed things you didn't ask for, discard the reply and keep your saved file.

6. Stop prompting once it's close

Each extra round is another chance to lose something. When the page is about 90% right, make the remaining changes directly in the code.

Start fresh when a chat gets long

If replies keep getting worse, open a new chat, upload your latest saved file, and describe only the next change. A short chat with a clean file often behaves better than a long one with many revisions.

Make the small edits yourself

A single HTML file is a text file. Changing a heading, a color, a phone number or a link takes a minute in any code editor, and nothing else on the page moves. That is the most reliable way to avoid a rewrite.

A practical routine:

  1. Copy the full code out of Canvas into a file named index.html.
  2. Open it in a code editor and make the change yourself.
  3. Open the file in your browser and check it.
  4. If you need a bigger change, ask Gemini for that one section only, paste the new section into your file by hand, and diff before you save.

Where to look for common edits:

  • Text: search the file for the old wording and replace it.
  • Colors: look for hex values like #1a1a1a in the <style> block, or in CSS variables near the top.
  • Links and phone numbers: search for href=.
  • Images: search for src=.

Don't treat the canvas as your only copy

If saving fails once, you can lose the page. Keep a local file after every version that works.

What won't help

  • Repeating the request more firmly. Rephrasing the same prompt tends to produce another full rewrite.
  • Asking it to "undo". The model has to rebuild an earlier version, and the result may not match what you had.
  • Adding more detail about the whole page. A longer prompt gives the model more reason to touch more of the file.

Checklist before you prompt again

  • The current working version is saved in a local file.
  • Your prompt names one change and says what must stay the same.
  • The model is working from the file you uploaded or the latest canvas, not an older paste.
  • You have a way to compare old and new output.
  • You know which part you'd rather edit by hand.

If nothing works

If Canvas keeps rewriting or losing your work after you've tried the above, report it to Google through the feedback option in Gemini or the Gemini Apps help center. Include the exact behavior, roughly when it happened, which model version the chat showed, and what you already tried. Screenshots of the before and after help.

Subject: Gemini Canvas rewrites the whole file on small edits

When I ask Canvas for a single change (for example, changing one heading),
it regenerates the entire HTML file and alters unrelated sections.
Date/time of the latest occurrence: [date, time zone]
Model shown in the chat: [model name]
What I tried: selecting the part on the canvas, telling it to keep
everything else unchanged, uploading the file instead of pasting.
Expected: only the selected part changes.
Actual: other sections of the code change or break.
Screenshots of the before and after are attached.

If the page also needs to be online

Liite partly covers this. If you want a link to share, you can upload the HTML file or a zip as an uploaded site, and it is served at <slug>.liite.site. The browser code editor is available on every plan, so you can fix a line and republish without another round with the model. AI edit is Pro and up, with a diff preview before you apply it, and it uses credits or your own key. Every publish is saved, and the Free plan keeps 3 versions for rollback.

Know the limits first. A Free uploaded site needs a card on file, is capped at 3 MB, and goes offline 7 days after the last publish. Liite doesn't run server-side code, so this suits static pages, not apps that need a backend. For the steps, see put an HTML file, a zip or a PDF online.

Common questions

Does Canvas always rewrite the whole file?

Not every time, but people report it often enough that it's safest to assume it might. Check each reply against your saved copy.

Why did Canvas delete the edits I made by hand?

Some people report that the model worked from an older copy and didn't see their manual edits. Upload or re-paste your latest version before the next prompt, and keep your own file as the source of truth.

Can I ask Gemini to return only a diff or a patch?

You can ask, and it sometimes helps for one section. Results vary, so paste any returned snippet into your own file by hand and compare before saving.

Is there a setting that turns off full rewrites?

We haven't found one documented. Check the Gemini Apps help center for current behavior, since the product changes often.