Skip to content

Snippets

The admin describes a snippet as “Reusable blocks of HTML your theme can embed anywhere by key.”

Three words in that sentence carry the whole feature.

Reusable — write it once, show it in many places. A shipping notice, a seasonal banner, a block of legal small print that appears on four pages.

By key — the theme asks for a snippet by name, its Embed key. The key is fixed once a snippet is created, so that embeds already in your theme keep working. To use a different key, create a new snippet.

HTML — this is raw markup, not a rich-text field. The Content field says so: “Raw HTML. The storefront sanitizes it before rendering, so scripts and event handlers are stripped.”

The storefront cleans the HTML before it shows it, so a script or an event handler you paste is removed rather than run. The editor also lists markup your storefront’s security policy blocks, under “Blocked by your storefront’s security policy”: an inline script, an event handler or a javascript: link. For a script, it says to load it from a URL and add that origin to the script allow-list in Settings.

That is a safety net, not a review. Raw HTML can still break a layout, so if you did not write a block and do not understand it, do not paste it here.

Each snippet has its own Content for every language, and a Show on the storefront switch that turns it off without deleting it. If the block needs to be scheduled, or edited by someone who does not write HTML, it wants to be a page or a content block instead. A snippet is for markup that is stable and technical.

  • It does not say what a theme renders when it asks for a key that no snippet has. The editor says only that a snippet that is off, has no content, or is deleted renders nothing wherever the theme embeds it.
  • It does not list which keys your theme uses. That belongs to the theme, and it changes when the theme does.