Which method you use depends on what you are adding and where it needs to show up. Here are the three routes, fastest first, so you can match the one you need and get back to your store.

Adding HTML code in the Shopify theme editor

Key Takeaways
1
To add HTML to one page or blog post: open the page in your Shopify admin, click the <> Show HTML button in the content editor, paste your code, and Save.
2
To add HTML without touching any theme files: go to Online Store, then Themes, then Customize, then Add section and choose Custom Liquid. Paste your code and Save.
3
To add HTML across the whole store, such as a verification tag in the header: go to Online Store, then Themes, open the … button, choose Edit code, open Layout and then theme.liquid, and paste your code above the closing head tag. Duplicate the theme first so you keep a safe copy.

Add HTML to a single page or blog post

Use this when the code belongs to one page, such as a table, a block of formatted text, or a button inside the page content.

  1. In your Shopify admin, open Online Store and then Pages (or Blog posts), and open the page you want to edit.
  2. In the content box, click the <> Show HTML button on the toolbar. The editor switches from the visual view to the raw HTML.
  3. Paste your HTML where you want it to appear, then switch back to the visual view and check that it looks right.
  4. Click Save.

One thing the page editor does quietly: it removes script, style and iframe tags when you Save. If your code disappears after saving, that is why, and you want the Custom Liquid method below instead.

Add HTML with a Custom Liquid section (no code files)

This is the safest way to drop a widget, an embed or a snippet onto a page without opening any theme files. A broken Custom Liquid section only affects itself, so it can never take down the rest of your store.

  1. Go to Online Store, then Themes.
  2. Click Customize on your live theme to open the theme editor.
  3. Pick the page you want from the dropdown at the top of the editor (home page, product pages, and so on).
  4. Click Add section, or Add block inside an existing section, and choose Custom Liquid.
  5. Paste your HTML or Liquid into the box, then click Save.

Because this lives in the theme settings rather than the theme files, you can move it, hide it or delete it at any time from the same editor.

Add HTML to the theme files (site-wide code)

Use this when the code has to load on every page, for example a Google verification tag, an analytics snippet or a font in the header.

  1. Go to Online Store, then Themes.
  2. On the theme you want, click the … button (some stores show this as an Actions menu) and choose Edit code.
  3. Under Layout, open theme.liquid.
  4. Find the closing head tag and paste your code just above it. For code that should load in the page body instead, paste it above the closing body tag.
  5. Click Save.

Editing theme files is the powerful option, and also the one that can break your storefront, so read the next section before you save anything here.

What can break, and how to undo it

Shopify’s own guides show you where to paste code but say little about what happens when it goes wrong. This is the part that saves you.

A single mistake in theme.liquid, such as an unclosed tag or a stray Liquid bracket, can blank out every page that uses that layout, not only the one you were working on. That is why you duplicate the theme first. Go to Online Store, then Themes, click the … button, and choose Duplicate. Edit the copy, and only publish it once it looks right.

If a live edit has already caused a problem, you do not have to fix it by hand. Shopify saves older versions of your theme. Open Online Store, then Themes, click the … button on the theme and look for the theme version history, then roll back to the last good version.

A Custom Liquid section is the low-risk choice on purpose. If it misbehaves, open Customize, select the section, delete it, and Save. Nothing else on the store is touched.

Two limits are worth knowing before you start. The page editor strips script, style and iframe code on save, so anything interactive belongs in a Custom Liquid section or the theme files. And the checkout page will not accept custom HTML unless you are on Shopify Plus.