The Easy Way to Create JSON-LD Templates for eCommerce

eCommerce sites are notorious for the number of pages, canonicals, redirects, and site structure that the they contain. Seasonal pages like “Summer Sale’s” also play difficult roles, involving constant maintenance.

Implementing JSON-LD on large eCommerce sites can be accelerated through using a method called “Templating” and “Page Classification.”

JSON-LD problems with eCommerce stores.

Pages. Lots, and lots of pages. Whether it be simple duplicate content marked as canonical due to being a product variation, or if you are working for a mega store with more than 5,000 products, you will have to deal with a lot of pages.

Each product, while potentially being very similar to others, has to have unique content written for it, and often has to have unique structured data markup. That’s because no two products are the same, and if your customers know that, so should the Search Engines!

Writing structured data like JSON-LD, or even more time consuming, microdata, will be near impossible for a mega eCommerce site. Now there’s two possible solutions to this, both of which don’t provide your client with the best possible results:

Possibility #1. Using a pre-generated script from somewhere in the web.

Pre-generated scripts are great for general use, but not if you’ve been recruited to specifically look after the technical SEO of a website. A pre-generated script will include a lot of general schema.org markup which misses things like “aggregateRating,” or “locatedIn,” or even “sameAs.”

Possibility #2. Not applying JSON-LD to every product page.

While this will save a lot of hassle, and allow you to focus on more important pages like categories, informational pages, and maybe even things like articles submissions, you are cutting off the lifeline of the eCommerce. Having structured data on every product page is a must, because this is what drives revenue to the site.

So there is actually a third solution, which what we at SEOSPIDRE call “templating.”

Templating: The act of creating specific JSON-LD classes for important page types.

Templating, and Classification.

Templating, is the act of creating specific JSON-LD “classes” for important page types. Now what does that actually mean? Well, actually comes after page classification, once we know what the standard page types that we have are, we can begin creating JSON-LD templates for them.

For example, you might consider article posts a “class,” because of the common attributes that all of the posts share. They are all text and image based, share the idea of driving traffic towards the site, and are pretty simplistic in function. They don’t have peripheral features like search functions, purchasing availability, or stock, so it makes it a pretty simple class! We’ll call this class the “article class.”

Now, upon further analysis we find that product pages generally share significant commonality. They might have different prices, names, ratings, and SKU’s, but they all functionally require the same structured data and provide users with the same information. This would be an important class as well, so we’ll call this the “product class.”

I think you get the idea here, so you would rinse and repeat until you can identify the major pages for your site. At SEOSPIDRE, we find that, usually for an eCommerce, we create the following classes:

  • Product Class
  • Article Class
  • Category Class
  • Seasonal Sales Class
  • Nav-bar Class

Product, article, and category classes are pretty straightforward. “Seasonal sales Class” are groups of pages which are only around during specific months of the year, for example a “summer sale.” When we get into templating, you’ll realise that you will have to write specific JSON-LD for products that are on sale, and instead of having to re-write all the JSON-LD continuously, it’s best to have a class for this kind of information too.

The nav-bar class is the greatest amount of work. The nav-bar class has no single template to work form. The commonality of the nav-bar class is that all of the “key” pages are listed here, things like the Contact US, Store, Returns, About Us. Each of these pages have different structured data schemas, and in terms of functionality, have a very diverse range of values. So what the nav-bar class aims to do is to aggregate the JSON-LD for all of the nav-bar pages.

For example, the “Home” page will have quite an extensive JSON-LD as you will include site-wide information here. The “Contact Us,” page will have specific information regarding opening times, location, availability, and so forth. These JSON-LD’s are completely different from each other, but instead of having loose pieces of script lying around in random documents, it’s best to include all of these in a single directory for “nav-bar” pages.

Templating

Ok so we’ve got all the classes. Now we have to write specific JSON-LD templates that will streamline our work from here on forward. Templating involves writing general JSON-LD that includes the important keys, but not the values, which will be filled in per page.

A key/value pair is something often used in Python and database programming languages, which ES6 (JavaScript) includes as well (remember JSON-LD stands for JavaScript Object Notation – Linked Data). Key’s represent names of things, which can have value’s, denoted by a colon (“:”). So if we take a quick line of JSON-LD:

{
  "@context":"http://schema.org/",
}

“@context” is a string key, that is paired with the value “http://schema.org”.

So let’s take a slightly longer JSON-LD which I’ve written for our eCommerce, and you’ll see the difference between a complete JSON-LD, and a template JSON-LD.

// This is an example of a full JSON-LD which includes all of the key:value pairs. This would be
// used on a live page and would represent the essential details of a product.

<script type="application/ld+json">
{
    "@context": "http://schema.org/",
    "@type": "Product",
    "name": "Some Amazing Product",
    "image": "some-amazing-product.png",
    "description": "This is a really amazing product. In fact, we think you will be amazed.",
    "sku": “123456789",
    "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "4",
        "reviewCount": "1,987"
    },
    "offers": {
        "@type": "Offer",
        "priceCurrency": "USD",
        "price": "9.99",
        "availability": "http://schema.org/InStock"
    }
}
</script>

Now let’s compare that to a template, which will help us streamline our JSON-LD implementation.

// This is an example of a template JSON-LD which includes only the key values. This would not be
// used on a live page, and would be edited as necessary to form complete JSON-LD.

<script type="application/ld+json">
{
    "@context": "http://schema.org/",
    "@type": "Product",
    "name": " ",
    "image": " ",
    "description": " ",
    "sku": “ ",
    "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": " ",
        "reviewCount": " "
    },
    "offers": {
        "@type": "Offer",
        "priceCurrency": " ",
        "price": " ",
        "availability": "http://schema.org/InStock"
    }
}
</script>

What makes templating so powerful, is that we would copy and paste this product class template onto as many product pages as we want, and fill out the details based on the page. This prevents us from falling into either pitfall of Solution #1 / Solution #2 as stated in the introduction.

Now, you would have to create a template for each of your classes, of which the most work will be the nav-bar, considering they will each need their own “template,” so to speak. While this isn’t work-free, it’s a dramatic reduction in the work you will have to do to provide excellent quality results.

A final recap.

So the steps include finding the relevant, important pages and classifying them according to “classes.” With these classes we formulate templates, which we then extend onto the specific pages that belong to that class. Here’s a breakdown of what the steps look like:

  1. Identify pages that share structured data markup commonality, or functional commonality.
  2. Group these pages into “classes” that are easy to remember and expressive of their meaning.
  3. Go to http://schema.org and find the relevant JSON-LD structured data for your class.
  4. Write the JSON-LD template for the class, double checking to ensure that all of the schema is implemented properly.
  5. Check that the schema works by going to Google’s Developer Schema Testing Tool.
  6. Leave the values blank, ensure that the keys are correct, and all the information you want to be displayed is included.
  7. Copy and paste the template onto a relevant class page, and fill out the values as is correct to that specific page.
  8. Repeat for each class/page until JSON-LD is fully available on the site.

While not easy, templating is the quickest method to produce the highest value for your client. It’s also one of the only ways to handle large numbers of product pages efficiently, so as to not waste your time providing invaluable schema, or by skipping low-value pages altogether.

Leave a Reply