","programmingLanguage":"JAVASCRIPT","codeRepository":"https://fysalyaqoob.com/snippets/squarespace-schema-markup","url":"https://fysalyaqoob.com/snippets/squarespace-schema-markup","datePublished":"2025-11-28","dateModified":"2025-11-28","keywords":"squarespace, schema, seo, structured-data, json-ld","about":{"@type":"Thing","name":"seo","description":"seo development"},"educationalLevel":"beginner","isAccessibleForFree":true,"license":"https://opensource.org/licenses/MIT"}
JAVASCRIPTseobeginner

Add Schema Markup to Squarespace Website

Implement Schema.org structured data on Squarespace using Code Injection

Faisal Yaqoob
#squarespace#schema#seo#structured-data#json-ld
Share this snippet:

Code

javascript
1// Add to Settings > Advanced > Code Injection > Header
2<script type="application/ld+json">
3{
4 "@context": "https://schema.org",
5 "@type": "Organization",
6 "name": "Your Business Name",
7 "url": "https://yoursite.squarespace.com",
8 "logo": "https://images.squarespace-cdn.com/your-logo.png",
9 "description": "Your business description",
10 "telephone": "+1-555-123-4567",
11 "email": "info@yourbusiness.com",
12 "address": {
13 "@type": "PostalAddress",
14 "streetAddress": "123 Main Street",
15 "addressLocality": "New York",
16 "addressRegion": "NY",
17 "postalCode": "10001",
18 "addressCountry": "US"
19 },
20 "sameAs": [
21 "https://www.facebook.com/yourbusiness",
22 "https://www.twitter.com/yourbusiness",
23 "https://www.instagram.com/yourbusiness",
24 "https://www.linkedin.com/company/yourbusiness"
25 ]
26}
27</script>

Add Schema Markup to Squarespace Website

Implement Schema.org structured data on your Squarespace website to improve SEO and enable rich snippets in Google search results.

Organization Schema (Site-wide)

// Add to Settings > Advanced > Code Injection > Header
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "Your Business Name",
  "url": "https://yoursite.squarespace.com",
  "logo": "https://images.squarespace-cdn.com/your-logo.png",
  "description": "Your business description",
  "telephone": "+1-555-123-4567",
  "email": "info@yourbusiness.com",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "123 Main Street",
    "addressLocality": "New York",
    "addressRegion": "NY",
    "postalCode": "10001",
    "addressCountry": "US"
  },
  "sameAs": [
    "https://www.facebook.com/yourbusiness",
    "https://www.twitter.com/yourbusiness",
    "https://www.instagram.com/yourbusiness",
    "https://www.linkedin.com/company/yourbusiness"
  ]
}
</script>

LocalBusiness Schema

// Add to Settings > Advanced > Code Injection > Header
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  "name": "Your Business Name",
  "description": "Brief description of your business",
  "image": "https://images.squarespace-cdn.com/business.jpg",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "456 Market Street",
    "addressLocality": "Los Angeles",
    "addressRegion": "CA",
    "postalCode": "90001",
    "addressCountry": "US"
  },
  "geo": {
    "@type": "GeoCoordinates",
    "latitude": "34.0522",
    "longitude": "-118.2437"
  },
  "telephone": "+1-310-555-0100",
  "email": "contact@yourbusiness.com",
  "url": "https://yoursite.squarespace.com",
  "openingHoursSpecification": [
    {
      "@type": "OpeningHoursSpecification",
      "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
      "opens": "09:00",
      "closes": "17:00"
    },
    {
      "@type": "OpeningHoursSpecification",
      "dayOfWeek": "Saturday",
      "opens": "10:00",
      "closes": "14:00"
    }
  ],
  "priceRange": "$$",
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "4.7",
    "reviewCount": "142"
  }
}
</script>

Article Schema for Blog Posts

// Add to individual blog post > Settings > Advanced > Page Header Code Injection
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "Your Blog Post Title",
  "description": "Brief description of your blog post",
  "image": "https://images.squarespace-cdn.com/post-image.jpg",
  "author": {
    "@type": "Person",
    "name": "Author Name",
    "url": "https://yoursite.squarespace.com/about"
  },
  "publisher": {
    "@type": "Organization",
    "name": "Your Site Name",
    "logo": {
      "@type": "ImageObject",
      "url": "https://images.squarespace-cdn.com/logo.png"
    }
  },
  "datePublished": "2025-11-28",
  "dateModified": "2025-11-28",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://yoursite.squarespace.com/blog/post-title"
  }
}
</script>

Dynamic Blog Post Schema

<!-- Add to Settings > Advanced > Code Injection > Header (Blog Posts) -->
<squarespace:script src="jquery" />
<script>
$(document).ready(function() {
  // Only run on blog posts
  if ($('body').hasClass('collection-type-blog')) {
    // Get blog post data
    var title = $('h1.entry-title').text();
    var description = $('meta[property="og:description"]').attr('content');
    var image = $('meta[property="og:image"]').attr('content');
    var author = $('.author-name').text() || 'Your Name';
    var datePublished = $('time.published').attr('datetime');
    var url = window.location.href;

    // Create schema
    var schema = {
      "@context": "https://schema.org",
      "@type": "BlogPosting",
      "headline": title,
      "description": description,
      "image": image,
      "author": {
        "@type": "Person",
        "name": author
      },
      "publisher": {
        "@type": "Organization",
        "name": "Your Site Name",
        "logo": {
          "@type": "ImageObject",
          "url": "https://images.squarespace-cdn.com/logo.png"
        }
      },
      "datePublished": datePublished,
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": url
      }
    };

    // Inject schema
    var script = document.createElement('script');
    script.type = 'application/ld+json';
    script.text = JSON.stringify(schema);
    document.head.appendChild(script);
  }
});
</script>

Product Schema for E-commerce

// Add to individual product page > Settings > Advanced > Page Header Code Injection
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Product",
  "name": "Product Name",
  "description": "Detailed product description",
  "image": [
    "https://images.squarespace-cdn.com/product-1.jpg",
    "https://images.squarespace-cdn.com/product-2.jpg"
  ],
  "brand": {
    "@type": "Brand",
    "name": "Brand Name"
  },
  "sku": "PROD-123",
  "offers": {
    "@type": "Offer",
    "url": "https://yoursite.squarespace.com/shop/product-name",
    "priceCurrency": "USD",
    "price": "49.99",
    "availability": "https://schema.org/InStock",
    "priceValidUntil": "2026-12-31",
    "seller": {
      "@type": "Organization",
      "name": "Your Store Name"
    }
  },
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "4.8",
    "reviewCount": "67"
  }
}
</script>

Dynamic Product Schema

<!-- Add to Settings > Advanced > Code Injection > Header (Product Pages) -->
<squarespace:script src="jquery" />
<script>
$(document).ready(function() {
  // Only run on product pages
  if ($('body').hasClass('ProductItem')) {
    // Get product data
    var productName = $('.ProductItem-details-title').text().trim();
    var description = $('meta[property="og:description"]').attr('content');
    var image = $('meta[property="og:image"]').attr('content');
    var price = $('.product-price').text().replace('$', '').trim();
    var url = window.location.href;

    // Check availability
    var availability = $('.sold-out').length > 0
      ? "https://schema.org/OutOfStock"
      : "https://schema.org/InStock";

    // Create schema
    var schema = {
      "@context": "https://schema.org",
      "@type": "Product",
      "name": productName,
      "description": description,
      "image": image,
      "offers": {
        "@type": "Offer",
        "url": url,
        "priceCurrency": "USD",
        "price": price,
        "availability": availability
      }
    };

    // Inject schema
    var script = document.createElement('script');
    script.type = 'application/ld+json';
    script.text = JSON.stringify(schema);
    document.head.appendChild(script);
  }
});
</script>

FAQ Schema

// Add to FAQ page > Settings > Advanced > Page Header Code Injection
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "What is your shipping policy?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "We offer free shipping on all orders over $50. Standard shipping takes 3-5 business days, and express shipping is available for 1-2 day delivery."
      }
    },
    {
      "@type": "Question",
      "name": "Do you accept returns?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Yes, we accept returns within 30 days of purchase. Items must be in original condition with tags attached. Please contact our customer service team to initiate a return."
      }
    },
    {
      "@type": "Question",
      "name": "How can I track my order?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Once your order ships, you'll receive a tracking number via email. You can use this number to track your package on the carrier's website."
      }
    }
  ]
}
</script>

Event Schema

// Add to event page > Settings > Advanced > Page Header Code Injection
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Event",
  "name": "Event Name",
  "description": "Event description",
  "startDate": "2025-12-15T19:00:00-05:00",
  "endDate": "2025-12-15T22:00:00-05:00",
  "eventStatus": "https://schema.org/EventScheduled",
  "eventAttendanceMode": "https://schema.org/OfflineEventAttendanceMode",
  "location": {
    "@type": "Place",
    "name": "Venue Name",
    "address": {
      "@type": "PostalAddress",
      "streetAddress": "789 Event Street",
      "addressLocality": "Chicago",
      "addressRegion": "IL",
      "postalCode": "60601",
      "addressCountry": "US"
    }
  },
  "image": "https://images.squarespace-cdn.com/event.jpg",
  "offers": {
    "@type": "Offer",
    "url": "https://yoursite.squarespace.com/events/event-name",
    "price": "25.00",
    "priceCurrency": "USD",
    "availability": "https://schema.org/InStock",
    "validFrom": "2025-11-01"
  },
  "organizer": {
    "@type": "Organization",
    "name": "Your Organization",
    "url": "https://yoursite.squarespace.com"
  }
}
</script>

How to Add Code Injection in Squarespace

Site-wide Schema (All Pages):

  1. Access Code Injection
  • Go to Settings > Advanced > Code Injection
  1. Add to Header
  • Paste your schema code in Header section
  • Click Save
  1. Publish
  • Changes apply immediately to published site

Page-specific Schema:

  1. Select Page
  • Navigate to Pages panel
  • Click the page you want to edit
  1. Page Settings
  • Click the gear icon for page settings
  • Go to Advanced tab
  1. Page Header Code Injection
  • Paste your schema code
  • Click Save
  1. Publish
  • Click Save and changes go live

Collection-specific (Blog, Products):

  1. Edit Collection
  • Go to the collection page
  • Click collection settings gear icon
  1. Advanced Settings
  • Navigate to Advanced tab
  • Use Page Header Code Injection
  1. Dynamic Code
  • Use jQuery to extract page data
  • Generate schema dynamically

Using Squarespace Built-in Data

// Access Squarespace data with JavaScript
<squarespace:script src="jquery" />
<script>
$(document).ready(function() {
  // Get meta tags
  var title = $('meta[property="og:title"]').attr('content');
  var description = $('meta[property="og:description"]').attr('content');
  var image = $('meta[property="og:image"]').attr('content');
  var url = $('meta[property="og:url"]').attr('content');

  // Get page elements
  var heading = $('h1').first().text();
  var datetime = $('time').attr('datetime');

  // Use this data to build schema
  var schema = {
    "@context": "https://schema.org",
    "@type": "WebPage",
    "name": title || heading,
    "description": description,
    "image": image,
    "url": url || window.location.href
  };

  // Inject schema
  $('head').append(
    '<script type="application/ld+json">' +
    JSON.stringify(schema) +
    '<\/script>'
  );
});
</script>

Testing Your Schema

  1. Google Rich Results Test
  1. Schema Validator
  1. Browser Console
  • View page source (Ctrl+U or Cmd+U)
  • Search for "application/ld+json"
  • Verify schema appears

Requirements

  • Code Injection: Available on Business and Commerce plans
  • jQuery: Use <squarespace:script src="jquery" /> for dynamic scripts
  • Published Site: Schema only appears on published site, not preview

Best Practices

  • Use absolute URLs: Always include full https:// URLs
  • Test on published site: Code injection doesn't show in preview
  • Page-specific vs Site-wide: Use site-wide for Organization, page-level for content
  • Keep data current: Update schema when content changes
  • Validate before publishing: Use testing tools
  • Don't duplicate: Avoid adding same schema in multiple locations
  • Monitor performance: Track rich results in Google Search Console

Common Squarespace Selectors

// Useful jQuery selectors for Squarespace
'.ProductItem-details-title'    // Product name
'.product-price'                 // Product price
'.sold-out'                      // Out of stock indicator
'.entry-title'                   // Blog post title
'time.published'                 // Publish date
'.author-name'                   // Author name
'h1'                            // Main heading
$('meta[property="og:..."]')    // Open Graph meta tags

Advanced: Schema for Multiple Products

// Generate schema for all products in collection
<squarespace:script src="jquery" />
<script>
$(document).ready(function() {
  if ($('body').hasClass('collection-type-products')) {
    var products = [];

    $('.grid-item').each(function() {
      var name = $(this).find('.grid-item-title').text();
      var price = $(this).find('.product-price').text().replace('$', '');
      var image = $(this).find('img').attr('data-src');

      products.push({
        "@type": "Product",
        "name": name,
        "offers": {
          "@type": "Offer",
          "price": price,
          "priceCurrency": "USD"
        },
        "image": image
      });
    });

    var schema = {
      "@context": "https://schema.org",
      "@type": "ItemList",
      "itemListElement": products
    };

    var script = document.createElement('script');
    script.type = 'application/ld+json';
    script.text = JSON.stringify(schema);
    document.head.appendChild(script);
  }
});
</script>

Features

  • Built-in jQuery: Easy DOM manipulation
  • Code Injection: Simple implementation
  • Dynamic Schema: Auto-generate from page content
  • E-commerce Ready: Product and offer schemas
  • Blog Optimized: Article and blog posting schemas
  • Event Support: Event schema for Squarespace Events
  • SEO Boost: Improve search visibility
  • Rich Snippets: Enable enhanced search results

Related Snippets