CardKit
Small tools for website editing and template work

GUIDE

How to Edit Squarespace Custom Code Without Rebuilding the Section

Squarespace handles normal page content visually. Custom HTML sections are the exception, and they get harder to maintain the moment you only need to change one small thing.

CardKit is an independent tool and is not affiliated with Squarespace. Nothing here is official guidance from Squarespace.

Introduction

A code block is a great way to get a layout that the standard blocks cannot produce. The problem appears six months later, when you want to change one phone number inside it and the block is four hundred lines long.

You have two options: rebuild the block from scratch, or make a controlled edit to the code you already have. The second is almost always faster and much less risky, provided you follow a workflow.

1. When custom code becomes difficult

The same set of problems shows up repeatedly:

  • Long HTML blocks with no indentation
  • Deeply nested elements
  • Image URLs buried several levels down
  • Buttons that are hard to locate among similar markup
  • Accidental CSS edits that change more than intended

None of these are reasons to avoid custom code. They are reasons to stop editing it by eye in the code panel.

2. Copy the original section

Before you change anything, copy the entire contents of the code block into a text file. This is your rollback, and Squarespace does not keep a convenient version history for the inside of a code block.

Name it after the block and the date, for example hero-code-2026-10.txt.

3. Identify the section rather than the whole page

A code block usually contains one component, not an entire page. Work with that component alone.

This matters for a practical reason: a visual editor that renders a whole document has to load its stylesheets, scripts and fonts, and half of those will not resolve outside the site. A single section renders reliably and previews accurately.

4. Edit visible content

With the section isolated, the edits you actually want are:

  • Text - headings, paragraphs, labels
  • Images - the image URL and its alt text
  • Buttons - the label and the destination
  • Links - where they point, and whether they open in a new tab

The CSS Code Editor is built for exactly this list: you paste the block, click the element, and change its value. Structure, classes and every other attribute are left as they were.

5. Be careful with CSS classes

Class names are the contract between the markup and the styles. If a block uses class="card card--wide" and you rename it to class="my-card", every rule written for the old name stops applying, and the block quietly loses its styling.

Do not rename a class unless you also update the CSS that targets it. If you do not know where that CSS lives, do not rename it.

The same applies to IDs. An ID may be an anchor target for navigation, or a hook for a script. Removing it can break a menu link that has nothing to do with the block you were editing.

6. Check responsive behaviour

Squarespace applies its own responsive rules around your block, but the contents of the block are yours. Check three widths before you publish:

  • Desktop - the layout you designed
  • Tablet - where two-column layouts usually start to tighten
  • Mobile - where text length and image height cause the most trouble

7. Paste the final section back

Replace only the contents of the code block you were editing. Do not paste over neighbouring blocks, and do not paste a full HTML document into a block that expects a fragment. A stray <html>, <head> or <body> tag inside a code block is a common cause of a page that renders strangely.

8. When not to use this workflow

Some things should not be edited with a small visual tool:

  • Complex JavaScript applications
  • Member systems and gated content
  • Checkout or payment code
  • Authentication
  • Server-side systems
  • Unknown third-party integrations

Limitation: a focused editor is for focused content changes. If the block runs logic you do not understand, changing it visually is not safer than changing it by hand.

Conclusion

Use a focused editor for focused content changes. Isolate the block, keep the original, change only the values you need, check three widths, then paste the block back.

Try the CSS Code Editor

Related tools

CSS Code Editor for the edit, and HTML Cleaner to re-indent a block that arrived as one long line.