How to stop clients from breaking your site layout
By Yash Garg · · 6 min read
You stop clients from breaking your layout by making sure they can only reach content, never the code that arranges it. In practice that means four guardrails: editable copy lives in typed data files, layout files need your review before they merge, every change gets a preview, and the editing tool you give the client only exposes text, images and list items.
None of these needs a new platform. They are settings and file conventions in the repository and host you already use.
How client edits break layouts
Most layout breakage comes from a short list of causes:
- Text far longer than the design expects. A three-word button label becomes a sentence and wraps onto two lines.
- Huge or oddly shaped images. A portrait photo lands in a landscape slot, or a multi-megabyte file slows the page.
- Edits inside JSX. A deleted closing tag or class name changes the structure, not just the words.
- A missing field in a list item. One pricing card without a price renders an empty box.
- Changes to shared components. Editing a header file to fix one page changes every page.
Each guardrail below closes one or more of these.
Guardrail 1: keep editable copy in data files
Move the text and image paths a client will change out of components and into plain data files, one per page or section. The layout imports the data; the client edits the data. Our guide to letting clients edit a Next.js site without a CMS walks through the file layout in detail, so here we focus on what happens next: making those files hard to get wrong.
Guardrail 2: type your content objects
If your site uses TypeScript, give every content file a type. TypeScript lets you name an object's shape with an interface or a type alias, so a pricing card can require a name, a price and a list of features. When a client's edit drops the price, the type check fails and, if your build or CI runs the type checker, the broken card never ships.
Three type features map directly onto layout risk:
| Layout risk | Type feature | Example |
|---|---|---|
| A required field goes missing | Required properties | Every pricing card must have a price |
| Some items don't need a field | Optional properties with ? | A badge only on the featured plan |
| A style choice outside your design | A union of literal types | Button style must be "primary" or "secondary" |
The handbook shows how combining literals into unions restricts a value to a known set, which is how you stop a client typing "big red" into a field your CSS only understands as "primary". You can also mark properties readonly, though the handbook notes it won't change any behavior at runtime, so treat it as documentation for developers rather than protection.
Types can't limit text length. For that, write a short content guide (for example, "hero headline: 60 characters or fewer") and test the longest realistic value on a preview.
Guardrail 3: protect the branch and own the layout files
Branch protection decides what can reach your production branch. GitHub's protection rules can require pull request reviews and passing status checks before changes merge, so a type check or build becomes a gate rather than a suggestion.
CODEOWNERS adds path-level control. GitHub says code owners are automatically requested for review when a pull request touches files they own, and the "Require review from Code Owners" option in branch protection makes their approval mandatory.
An example ownership plan for a marketing site:
| Path | Owner | Effect |
|---|---|---|
| /app/ and /components/ | You | Layout changes wait for your approval |
| /.github/ | You | Nobody can quietly rewrite the ownership file |
| /content/ | No extra owner | Copy edits follow the normal review rule |
The same docs say to give the CODEOWNERS file itself an owner, that the file must be on the pull request's base branch, and that code owners in private repositories need a paid GitHub plan.
Guardrail 4: use rulesets for finer control
Rulesets are GitHub's newer way to express the same protections. Unlike branch protection rules, multiple rulesets can apply to the same branch at once, and you can switch one off without deleting it. On the GitHub Team plan, push rulesets for private repositories can restrict file paths, extensions and file sizes, and they apply to every push to the repository. That is a blunt way to block oversized uploads, so give yourself bypass permission.
Guardrail 5: preview every change
A preview is where layout problems show up before the live site sees them. Netlify, for example, builds a Deploy Preview automatically when you open a pull request in a connected repository, as long as the base branch is a production branch or has branch deploys enabled. Check each preview at phone width, with the longest headline and the largest image the client might realistically use.
Guardrail 6: set image rules before the first upload
Image problems are the most common layout surprise because a photo straight from a phone looks fine to the client. web.dev notes that serving desktop-sized images to mobile devices can use 2 to 4x more data than needed. Give the client a written spec per slot. Example values for a typical site:
| Slot | Shape | Example max width |
|---|---|---|
| Hero | Landscape, 16:9 | 1920 px |
| Team photo | Square | 800 px |
| Logo strip | Transparent PNG or SVG | 400 px |
Guardrail 7: limit what the editor can touch
The editing tool is the last guardrail. GitHub's web editor exposes every file. A Git-based CMS exposes only the fields you define. A visual editor that writes back to source can restrict changes to text, links, images and list items. TurnIntoCMS works that way: it writes each edit at its exact place in the syntax tree so class names and structure stay as they were, and clients can't create new layouts. If you are weighing a page builder that lets editors rearrange sections, read how Builder.io compares or compare client editing tools.
Layout guardrail checklist
- Editable copy and image paths live in data files
- Each content file has a TypeScript type with required fields
- Style choices use literal unions, not free text
- The production branch requires reviews and a passing build
- CODEOWNERS covers layout folders and .github
- Every change builds a preview checked at phone width
- The client has a written image and text length spec
- The editing tool only exposes content fields
Common mistakes
- Typing content but never running the type checker. Types catch nothing if the build skips them. Fix: run the type check in CI as a required status check.
- CODEOWNERS on the wrong branch. Fix: commit it to the branch your pull requests target.
- Free text for design choices. Fix: replace with a literal union.
- No owner for .github. Fix: add yourself as its code owner.
- Image rules agreed verbally. Fix: put them in the handoff document.
For the full handover process, see the client handoff guide for agencies.
FAQ
Can I stop clients editing layout files on GitHub?
Yes. Require pull request reviews on the production branch and list yourself as code owner for layout folders, so changes there can't merge without you.
Do TypeScript types stop a client entering very long text?
No. Types check the shape of content, not its length, so pair them with a written length guide and a preview check.
What image size should clients upload?
Agree a maximum width per slot, for example 1920 px for a full-width hero, and ask clients to resize before uploading.
Does a Git-based CMS prevent layout breakage?
It helps, because clients only see the fields you configure, but you still need branch protection and previews to catch content that doesn't fit the design.
Sources
- Object Types (typescriptlang.org, checked November 18, 2026)
- Everyday Types (typescriptlang.org, checked November 18, 2026)
- About protected branches (docs.github.com, checked November 18, 2026)
- About code owners (docs.github.com, checked November 18, 2026)
- About rulesets (docs.github.com, checked November 18, 2026)
- Deploy Previews (docs.netlify.com, checked November 18, 2026)
- Serve responsive images (web.dev, checked November 18, 2026)