A working inline SVG diagram on a Shopify page (product, blog post, or category) with complete ImageObject schema, full accessibility attributes, and brand styling that matches your theme. Total time: 30 minutes for the first one, 5-10 minutes for each additional diagram.
This guide assumes you have access to your Shopify theme code (Customize โ Actions โ Edit code, or via the Shopify CLI). If you can't edit the theme directly, you can still use the "Custom Liquid" section in the visual editor to inject SVG on individual pages, but theme-level integration is cleaner for diagrams used across many pages.
Step 1: Decide where the diagram lives
Two patterns, pick one:
- Inline directly in a template โ for one-off diagrams specific to a single article or product. Edit
templates/article.liquidfor blog posts,sections/main-product.liquidfor product pages, or whatever template owns the page. - Liquid snippet โ for diagrams reused across many pages (a brand-positioning diagram on every product, a category-tree visual in the global nav). Create
snippets/diagram-NAME.liquidand include it via{% render 'diagram-NAME' %}.
Step 2: Write the SVG
Start with a basic template. Here's a minimal example โ a 2-bar comparison chart you can adapt:
<figure>
<svg viewBox="0 0 400 200" role="img"
aria-labelledby="my-diagram-title my-diagram-desc"
width="100%" height="auto">
<title id="my-diagram-title">Conversion rate comparison</title>
<desc id="my-diagram-desc">
Bar chart comparing conversion rates before and after
adding inline diagrams to product pages.
</desc>
<line x1="30" y1="170" x2="380" y2="170"
stroke="#6B7F94" stroke-width="1"/>
<rect x="80" y="100" width="100" height="70"
fill="#FF5733" rx="2"/>
<rect x="220" y="50" width="100" height="120"
fill="#00FFB3" rx="2"/>
<text x="130" y="190" text-anchor="middle"
fill="#B8C9D9" font-size="12">Before</text>
<text x="270" y="190" text-anchor="middle"
fill="#B8C9D9" font-size="12">After</text>
<text x="130" y="95" text-anchor="middle"
fill="#F5EFE6" font-size="13" font-weight="bold">1.8%</text>
<text x="270" y="45" text-anchor="middle"
fill="#F5EFE6" font-size="13" font-weight="bold">3.4%</text>
</svg>
<figcaption>
Conversion rate uplift after adding inline diagrams.
</figcaption>
</figure>
The pattern: viewBox for scaling, role="img" + aria-labelledby for accessibility, <title> and <desc> elements as first children of the SVG, brand-palette colors only (cyan, mint, coral, purple, white, body, muted), text at 11-14px.
Step 3: Add to your Liquid template
If you went with Path A (inline): open the relevant template in Shopify's code editor and paste the SVG block. For a blog post diagram, you'd put it in templates/article.liquid just below the title:
<article class="article">
<h1 class="article__title">{{ article.title }}</h1>
<!-- Inline SVG diagram goes here -->
<figure>
<svg ...>...</svg>
<figcaption>...</figcaption>
</figure>
<div class="article__content rte">
{{ article.content }}
</div>
</article>
If you went with Path B (snippet): create a new file at snippets/diagram-conversion-rates.liquid containing just the <figure> block. Then include it in any template:
<!-- In any .liquid template -->
{% render 'diagram-conversion-rates' %}
Snippets accept parameters too, so you can make a single diagram template that varies by passed-in data โ useful for category-specific or product-specific variants:
{% render 'diagram-product-comparison',
left_value: product.metafields.custom.before_score,
right_value: product.metafields.custom.after_score %}
Step 4: Add ImageObject schema
Every substantive inline diagram should be paired with an ImageObject schema in the page <head>. This declares to AI crawlers that the diagram exists as a citable asset. Most Shopify themes have a snippets/structured-data.liquid (or similarly named) snippet where SEO schemas are added.
Add a conditional block that outputs ImageObject schema when the relevant page is being rendered:
{% if template contains 'article' and article.handle == 'my-article' %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "ImageObject",
"name": "Conversion rate comparison",
"description": "Bar chart comparing conversion rates before and after adding inline diagrams to product pages.",
"contentUrl": "{{ canonical_url }}#diagram-conversion-rates"
}
</script>
{% endif %}
The contentUrl field should point at a unique anchor on the page where the diagram lives. Add the matching id attribute to the <figure> element:
<figure id="diagram-conversion-rates">
<svg ...>...</svg>
<figcaption>...</figcaption>
</figure>
Step 5: Test and validate
- Theme editor preview: open the page in the Shopify theme editor and confirm the diagram renders correctly alongside the rest of the page.
- Mobile viewport: resize to 320px width (Chrome DevTools' device toolbar). Confirm the diagram scales down, labels remain readable, no horizontal scroll.
- Accessibility: use VoiceOver (Mac) or NVDA (Windows) to read the page. Confirm the screen reader announces the diagram title and description.
- Schema validation: paste the page URL into Google's Rich Results Test and verify the ImageObject schema is detected without errors.
- Live spot-check: after deploying, view the live page and verify everything still renders. If you used a snippet, view multiple pages that use that snippet to confirm consistency.
What can go wrong
Three common issues and their fixes:
The SVG renders but the theme editor warns about it. Shopify's editor sometimes flags inline SVG as "potentially unsafe HTML." This is a false positive โ inline SVG is completely safe (it's standard HTML5). The warning doesn't block the diagram from rendering on the live site.
Labels overlap on mobile. You probably have labels that are too long for the viewport at 320px width. Pre-format multi-line labels by hand (don't rely on text-splitting at runtime). Or shorten the label text.
Screen reader doesn't announce the diagram. Check that role="img" is on the <svg> element, aria-labelledby points at the correct IDs, and <title> and <desc> elements exist as direct children of the SVG (not nested deeper).
From one diagram to a system
After your first diagram, the pattern is: snippet per diagram, ImageObject schema per snippet, conditional rendering in the SEO snippet. Once you've built three or four, you'll have established a template that any future content can reuse in minutes rather than the initial 30.
For the full 12 diagram types that work well in ecommerce content, see the 12 inline diagram types every ecommerce SEO page should use. For the citation-strategic reason this matters, see why visual diagrams make content citable by AI search. For the deeper pillar on inline diagrams as a concept, see inline diagrams in the glossary.