How do I add custom code to Squarespace?

How do I add custom code to Squarespace?

Reading Time: 2 minutes

TL;DR: Use Code Injection for site-wide scripts in the header or footer, a Code Block for per-page HTML, CSS or JavaScript, and Custom CSS for styling. Advanced template control requires Developer Mode on eligible plans.

Squarespace exposes several distinct code entry points, and choosing the right one avoids most breakage.

Step 1 Match the scope to the tool

Site-wide changes belong in Code Injection, page-specific widgets belong in a Code Block, and visual tweaks belong in Custom CSS. Mixing these up is why people paste the same snippet onto a dozen pages.

Step 2 Use Code Injection for global scripts

Found in site settings, this adds markup to the head or footer of every page. It is correct for analytics, verification tags, font loading and site-wide scripts.

Step 3 Use a Code Block for embeds

Add HTML, CSS or JavaScript to a specific page or section for calculators, embeds and one-off widgets. Keep the code self-contained so it does not depend on global state.

Step 4 Use Custom CSS for styling

Apply styling globally or per page without touching structure. This is the safest way to adjust typography, spacing and colours beyond what the style panel offers.

Step 5 Consider Developer Mode only with a developer

Developer Mode exposes underlying template files for full control, but typically disables automatic template updates and shifts compatibility responsibility onto you. It suits teams with engineering support rather than a solo business owner.

Step 6 Verify plan eligibility

Code injection and advanced features are not available on every tier, and plan structures have changed over time. Confirm what your current plan includes before promising a capability.

Step 7 Protect performance

Header scripts block rendering, so load third-party scripts asynchronously or deferred where possible, and measure speed before and after adding anything.

Step 8 Keep external copies and test mobile

Custom CSS can be overridden by platform updates or conflict with built-in classes, so keep a documented copy externally. Test on a phone after any injection, because desktop-safe widgets frequently break narrow layouts. Use a staging duplicate for anything non-trivial.

Back to How-To

Was this helpful?

Thanks for your feedback!

Comments are closed