Remove invalid structured data from your Shopify theme
When JSON-LD for SEO is installed, it provides the structured data your Shopify store needs for products, business info, blog posts, and other things.
Most of the time, that’s all you need.
But sometimes your theme also has structured data, and sometimes that structured data is broken.
You don’t need to remove your theme’s data unless you’re also using Google’s Merchant Center with Shopify (which is super strict about structured data).
Google Search can use multiple sets of structured data, they’ll just use the most correct and complete set they find on a page. Here are some more details about how Google interacts with multiple sets of structured data.
But sometimes you still want to clean up your theme’s structured data. Either because it’ll be easier to understand, or to remove extra reports in Google’s Search Console, or maybe because Google Merchant Center is complaining about your theme’s microdata.
Whatever the reason, sometimes it makes sense to edit your theme and remove all of its structured data.
You will need a bit of experience with HTML so you might need to ask someone or hire someone to help if you’re unsure.
There are two types of structured data that a Shopify theme can use. The older style is called microdata and it’s structured data that’s mixed in with HTML code. The second style is more modern and is called JSON-LD.
JSON-LD is the same format that I use in my app and is Google’s recommended format, but if your theme is missing parts of its data then you still might want to remove it and replace it with my app.
Step 1. Backup
First, you’ll want to take a backup copy of your theme. Just in case.
Step 2. Find all of the microdata
Second, search through your theme for the theme’s microdata structured data. There are a few keywords you can use for this.
- itemtype – the type of data
- itemprop – the values of a piece of data
- itemscope
All of these combined make up your microdata.
Some themes have moved away from microdata or only have a few leftover pieces of code. So if you don’t find any, that’s ok. Keep going.
Step 3. Remove each piece of microdata
As you find each piece of microdata you’ll want to remove it.
Some will be attached to HTML components you want to keep, like your price display and product name. Others will be hidden elements like meta or span tags. This is where HTML expertise will help.
When in doubt, only delete the specific piece of code (e.g. itemtype="price"
) instead of the whole line.
As you’re editing your theme you’ll want to refresh the pages in your store to make sure they still look correct.
Step 4. Find all of the JSON-LD data
Now you’ll repeat that process but for the JSON-LD formatted data. Search through your theme for ld+json
(yes, it’s listed backward but that’s how JSON-LD data is defined).
Step 5. Remove each piece of JSON-LD data
If you find some JSON-LD data, there’ll be a script tag that encloses each piece. You’ll want to remove the script tags and the content inside them. For example, if you found this piece that describes a product you’d remove all of it.
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Product",
"description": "Shopify app that to get more organic search traffic from Google for your Shopify store, without having to fight for better rankings",
"url": "https://www.ilanadavis.com/products/json-ld-for-seo",
"name": "JSON-LD for SEO"
}
</script>
It may also be a Liquid object for structured data that doesn't show all the details, just a few lines that look something like this:
<script type="application/ld+json">
{{ product | structured_data }}
</script>
In either case, remove everything including the script opening and closing tags.
Comment code instead
One alternative to removing the code is adding a comment around the script tags. This essentially neuters the code without deleting it.
{% comment %}
<script type="application/ld+json">
{{ product | structured_data }}
</script>
{% endcomment %}
Step 6. Check and test your data
After you’ve removed the structured data, make sure to check your Shopify store. You want to make sure the pages still look and function correctly.
You’ll also want to use Schema Markup Validator on the pages to make sure you’ve removed all of the correct data.
If something doesn’t look right and you can’t fix it, restore your backup from Step 1 and try again.
This process can take a few minutes or a few hours depending on how your theme was coded and your HTML expertise.
JSON-LD for SEO
Get more organic search traffic from Google without having to fight for better rankings by utilizing search enhancements called Rich Results.