Where Should I Place JSON-LD Schema Code in My Shopify Theme?

I am looking to add JSON-LD schema markup to my Shopify theme and am unsure where to place it. Below is the JSON-LD I want to use:

{
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  "name": "TechGear Store",
  "url": "https://techgear-shop.com",
  "priceRange": "$$",
  "image": "https://techgear-shop.com/assets/logo.png",
  "telephone": "+1-555-123-4567",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "123 Main Street",
    "addressLocality": "Austin",
    "addressRegion": "Texas",
    "postalCode": "78701",
    "addressCountry": "US"
  },
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "4.8",
    "reviewCount": "1500"
  },
  "hasReturnPolicy": {
    "@type": "MerchantReturnPolicy",
    "name": "30 Day Returns",
    "url": "https://techgear-shop.com/return-info"
  }
}

I have tried placing it in the main layout file before the closing head tag and also made a separate section, but when I validate my site, Google’s tool fails to detect the structured data. What would be the best way to implement this in a Shopify theme?

Placing it in theme.liquid before the closing head tag works fine for LocalBusiness schema. If Google’s testing tool isn’t picking it up, you’ve got a JSON syntax issue or something’s wrong with your Liquid implementation. Double-check you’re using proper script tags with type=“application/ld+json” and make sure no Liquid syntax is messing with your JSON format. I’ve seen extra whitespace or line breaks break validation. Try minifying your JSON first, then test again. Also make sure your site’s live and accessible to Google’s crawler - it won’t work on password-protected dev stores.

The placement looks right, but you might have a wrapping issue with your JSON-LD code. Make sure you’re using proper script tags: <script type="application/ld+json"> and </script>. I ran into the same thing when I first added schema markup to my Shopify store. What fixed it for me was checking the page source after publishing - sometimes Shopify’s minification messes up the JSON. Also, Google’s testing tool can be slow to pick up new structured data. Try the Rich Results Test tool instead of the old Structured Data Testing Tool. One last thing - check if you’ve got conflicting schema markup somewhere else in your theme that’s breaking validation.