Every guide to editing Shopify theme code starts with the same rule: duplicate the theme first. On camelway.eu, a small store with a few niche products, I often edited the live theme directly. That's a risk a small store can take, and one I wouldn't recommend to a store with more traffic, more products or more at stake.
So when do you really need the copy? For a single line from a tool you trust, such as a tracking or monitoring snippet, you can go straight into the live theme, because Shopify keeps earlier versions of every file you save. For anything bigger, it's duplicate, change, preview, and publish the copy once it works.
Most changes need no code at all. If you're about to paste a snippet into theme.liquid or adjust the look of a section, here's where each kind of change belongs, where theme.liquid lives, and how to undo a mistake.
Where each kind of change belongs
Pick the lightest tool that reaches what you need. The theme editor and Custom CSS survive theme updates far better than edited code, and they can't break the page structure. I'd open the code only when nothing else gets there, because every edited file is one more thing to carry over by hand when the theme updates.
| You want to | Use | Where |
|---|---|---|
| Change colors, fonts, sections and their order | Theme editor | Online Store, then Edit theme |
| Adjust the look of one section or the whole store | Custom CSS | Section settings, or Theme settings, then Custom CSS |
| Add a block of HTML to one page | Custom Liquid section or block | Theme editor, Add section or Add block, if your theme offers it |
| Add a snippet from a tool to every page | theme.liquid | Edit code, Layout folder, one line above the closing head tag |
| Change how a template works | Code editor | Edit code, on a duplicate of the theme |
Step 1: Duplicate your theme
In your Shopify admin, open Online Store, click the three-dot menu next to your current theme and choose Duplicate. The copy carries the theme's code and settings, while your products, collections, pages and images stay where they are, shared by every theme. A store on Basic, Grow or Advanced can hold up to 20 themes, and a Plus store up to 100, so delete old copies now and then before the library fills up.

The same menu offers Download theme file, which emails you a copy of the theme, and I'd keep that file as an offline backup before any larger change.
Step 2: Open the code editor and find theme.liquid
From the same menu, choose Edit code. The editor opens with the theme's files on the left, sorted into folders, and the one you'll use most is theme.liquid in the Layout folder. It's the frame that wraps every page Shopify renders, so a line pasted there reaches every page at once: the home page, the collections and every product page.

The other folders, so you know what you're looking at:
- Layout: theme.liquid, the frame around every page, and password.liquid for the password page.
- Templates and sections: the page types and the building blocks you arrange in the theme editor.
- Snippets: small pieces of code that other files include.
- Assets: the theme's own stylesheets, scripts and images.
- Config and locales: the theme's settings and its texts in every language.
The new editor makes this less scary than it used to be. It searches one file or every file in the theme, and Theme Check underlines problems in red as you type, such as scripts that block the page from loading or texts missing from a translation file (camelway.eu's theme.liquid showed four warnings when I took that screenshot).
The Timeline keeps earlier versions of each file you save; right-click an entry and choose Restore contents to bring one back. The history is finite, though, so don't count on the oldest versions being there forever.
Step 3: Paste a snippet in the right place
Most tools that ask you to paste code want it inside the head section of theme.liquid, and where exactly you put it counts. Paste a script on its own line directly above the closing </head> tag, so it loads before the rest of the page and after Shopify's own head content. A site verification tag, such as the one Google Search Console gives you, goes just after the opening <head> tag instead. The script line here stands for the one line your tool gives you:
{{ content_for_header }}
<!-- Pasted here: one line from a tool, above the closing head tag -->
<script src="https://example.com/your-snippet.js" defer></script>
</head>
Liquid, Shopify's template language, uses two kinds of brackets. Double curly braces print something, such as a product title, and curly braces with percent signs run logic, such as a condition or a loop. Never paste inside either kind of bracket, and never in the middle of another tag; a clean line of its own between two existing lines is always the safe spot. Then click Save.
Both CartHacker snippets install this way (full disclosure: they're our own tools). Core Web Vitals Monitoring and Trust Seals & Badges each ask for one line above the closing head tag in theme.liquid, and both load with the defer attribute, so the page never waits for them. What the monitoring measures is in the Core Web Vitals guide, and the evidence on badges in the trust badge research.
Step 4: Preview, test and publish
Preview the copy from its actions menu, and click through the pages your change touches on a real phone: a product page, a collection, the cart and the home page. When everything works, choose Publish on the copy. The old theme moves to your theme library, where one click publishes it again if something turns up later, so I'd keep it there for a couple of weeks.
Change the look without code: Custom CSS
Want bigger headings in one section, or a different button color across the store? For style changes like those, Custom CSS is safer than editing the theme's stylesheet, and Shopify offers it in two places. Theme settings, then Custom CSS, styles the whole store, up to 1,500 characters; the Custom CSS field at the bottom of a section's settings styles that section alone, up to 500 characters.

h2 {
font-size: 32px;
}
A few things aren't allowed there: @import, @charset and @namespace, the content property, and web addresses other than Shopify's own cdn.shopify.com. Custom CSS doesn't reach the checkout either. And it can stop working after a theme update if the update renames the classes your rules target, so open the affected pages and check them after every update you install.
What a theme update does to your edits
When your theme maker releases a new version, Shopify shows an Update button next to the theme; camelway.eu's live theme had version 16.0.0 waiting in that menu when I took the screenshot in step 1. Updating adds a new draft named Updated copy of your theme, and it leaves the live one alone until you publish it.
Theme editor settings come across. Code edits come across only when they don't conflict with the update; when they do, Shopify reports that the code edits couldn't be included, and you carry them over by hand. That's the price of editing code, so before updating, save a copy of every file you changed, or keep a list of your edits with the file and the line.
Apps built on Shopify's app embeds and app blocks avoid the problem entirely, because their code lives outside the theme files. The switches for those are shown in the app-by-app speed hunt.
Undoing a mistake
- One file went wrong: open it in the code editor, find the version you want in its Timeline, right-click and choose Restore contents.
- The whole change went wrong: publish the previous theme from your theme library.
- The theme itself is gone or broken: upload the theme file you downloaded as a backup.
GitHub and the Shopify CLI
Developers can connect a theme to a GitHub repository, so every change is versioned and reviewed, or work on a local copy with the Shopify command-line tool (the Shopify CLI) and push changes when they're ready. In my experience few small stores use either, and most don't need to. For a store that edits code every week, or has more than one person working on the theme, version control is worth the setup.
Add one line to theme.liquid and see every real visit
One snippet, or our WordPress plugin, shows the speed and traffic of every real visit, with an email the week your store gets slower. Free accounts keep 7 days of history, Premium keeps 180.
Start free monitoringAnd if something does break on a Tuesday afternoon, remember where the Timeline is. One right-click on Restore contents, and the file is back the way it was.
Sources
Shopify Help Center and camelway.eu2
- Shopify Help Center: Editing theme code, Adding custom CSS, Duplicating themes, Adding themes and Updating your theme.
- camelway.eu, Shopify admin, Online Store and code editor, October 5, 2026.

Discussion 0
Ask a question or share what you saw on your own store.
No comments yet.