Skip to main content
Shopify guide

How to Add Inline Diagrams to a Shopify Store

By ยท Updated ยท 4 read

Overview

Shopify's theme architecture supports inline SVG diagrams natively in any section, block, or template. The implementation pattern is the same as any HTML site, with a few Shopify-specific considerations around Liquid templating and the asset pipeline.

The basics

Inline SVG in a Shopify theme works in any `.liquid` template. You write the `<svg>` element directly into the template alongside the other markup. The Liquid template engine doesn't interfere with SVG syntax โ€” they're both valid HTML/XML and coexist cleanly.

For diagrams that appear on many pages (in headers, footers, or shared sections), put the SVG in a Liquid snippet (e.g., `snippets/diagram-citation-flow.liquid`) and include it via `{% render 'diagram-citation-flow' %}`. This keeps the theme files clean and the diagram source single-sourced.

For diagrams specific to one product or article, inline them directly in the relevant template (`templates/article.liquid` for blog posts, `sections/product.liquid` for product pages).

Shopify-specific gotchas

Theme editor preview can be confused by very complex SVGs (5000+ paths) and may lag. For ecommerce diagrams this is rarely an issue โ€” most useful diagrams are under 100 paths.

The Shopify Asset CDN doesn't apply to inline SVG (it's served as part of the page HTML). This is fine for diagrams under 10KB; for larger SVGs, consider whether you actually need them inline vs as a separate `.svg` file in `assets/` referenced via `{{ 'diagram.svg' | asset_url }}`.

Shopify's App Bridge and embedded apps don't support inline SVG the same way โ€” they have their own rendering context. For app development, use Polaris's icon system. This concern applies only to apps, not to the customer-facing theme.

A concrete example

On a product page, you might want a small inline SVG showing where your product fits in your category structure (a breadcrumb-style diagram). Add it inside `sections/main-product.liquid` between the product title and the description. Wrap it in `<figure>` with `<figcaption>` and add an `ImageObject` JSON-LD block to the page head (via the theme's SEO snippet) declaring what the diagram shows. Total implementation: ~30 minutes for the first instance, ~5 minutes for each additional diagram once you have the pattern.

Frequently asked questions

Does inline SVG work with all Shopify themes?

Yes โ€” inline SVG is standard HTML5, supported by any theme regardless of vendor or version. Theme-specific styling (the Shopify variable system, the section structure) doesn't affect SVG support.

Should I use a Shopify app to add diagrams, or build directly into the theme?

Build directly into the theme. Apps that add diagrams to pages typically inject them via JavaScript, which means they're not in the initial HTML โ€” AI crawlers won't see them. Theme-level inline SVG is in the initial HTML, fully crawlable. Apps add cost, complexity, and JavaScript dependencies for no SEO/citation benefit.

How do I add ImageObject schema in Shopify's SEO snippet?

In `snippets/structured-data.liquid` (or whatever your theme calls its SEO snippet), conditionally output the ImageObject JSON-LD block when the current page has a diagram. You can use Liquid conditionals (`{% if template == 'article' %}`) to scope this. For a global pattern, wrap it in a snippet (`snippets/image-object-schema.liquid`) that takes parameters for diagram name, description, and anchor URL.

MG
Written by

Matt is the founder of RunOctopus. He built All Angles Creatures from zero to page-1 rankings in reptile feeder insects in under 60 days using exactly this method โ€” turning a hard, entrenched niche into RunOctopus's proof store for programmatic SEO and AI search citation.

Connect on LinkedIn →

See what Otto would build for your store

Free architecture preview. No card required. Five minutes.

Generate Preview →