Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove structured data from archives and include some recommended fields on single product pages #22925

Merged
merged 10 commits into from Mar 5, 2019

Conversation

@mikejolley
Copy link
Member

commented Mar 4, 2019

  • Remove structured data from archives (pulled from #22912). This prevents the error "Either offers review or aggregateRating should be specified" since the data was limited.
  • Added review (resolves a warning in the testing tool) where available.
  • Added priceValidUntil (resolves a warning in the testing tool) which defaults to a year.
  • Added URL field (occasionally appears if there are no offers).
  • Added a fallback for SKU so it's never missing.

The only warning I see with these changes is a missing brand attribute. We should not include this as there is no brand field in WooCommerce. WooCommerce Brands adds this field as well as updates schema. There are other solutions out there too so thats out of scope for this PR.

To test, visit a product page (preferably once with reviews), view source, and copy the source into the testing tool: https://search.google.com/structured-data/testing-tool/u/0/

structured data testing tool 2019-03-04 13-26-04

Brand warning is expected - no brands exist in WC.
image warning is expected if you're testing on localhost and not a live site.

I've added a WIKI article here to cover customisation: https://github.com/woocommerce/woocommerce/wiki/Structured-data-for-products

Removes invalid product structured data from archives, and include more data on single product pages. Product structured data should only be generated for visible data, and not on archives when there are single product pages available, as per the documentation. Since this change removes structured data from archives, the filters woocommerce_structured_data_product_limit and woocommerce_structured_data_product_limited have also been removed. To customize product structured data, for example adding custom fields or include on archives despite Google guidelines, see this WIKI article. https://github.com/woocommerce/woocommerce/wiki/Structured-data-for-products

Fixes #22896

TimBHowe and others added some commits Feb 28, 2019

Remove woocommerce_structured_data_product_limit
With the removal of generation on archives, the filters `woocommerce_structured_data_product_limit` and `woocommerce_structured_data_product_limited` have no context nor purpose. This commit removes them so full schema is generated when used.

@mikejolley mikejolley added this to the 3.5.6 milestone Mar 4, 2019

@mikejolley mikejolley changed the title Fix/22896 Remove structured data from archives and include some recommended fields on single product pages Mar 4, 2019

'reviewRating' => array(
'@type' => 'Rating',
'ratingValue' => $rating,
'bestRating' => 5,

This comment has been minimized.

Copy link
@kloon

kloon Mar 4, 2019

Member

bestRating and worstRating can actually be omitted since it defaults to 5 and 1 when omitted.

'ratingValue' => $rating,
'bestRating' => 5,

This comment has been minimized.

Copy link
@kloon

kloon Mar 4, 2019

Member

Same as previous comment, these can be omitted since it defaults to 5 and 1.

@kloon

kloon approved these changes Mar 4, 2019

Copy link
Member

left a comment

Just a couple of not needed elements that was added, but good to merge with those in place.

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 4, 2019

tested on my website reempetstore.com, and i have been able to add new products with positive results, with only brand missing, while the old products are still showing errors and warnings.

@mikejolley

This comment has been minimized.

Copy link
Member Author

commented Mar 4, 2019

@aliirshad9 do you think caching is at play there? It's all generated the same way by WooCommerce.

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 4, 2019

@aliirshad9 do you think caching is at play there? It's all generated the same way by WooCommerce.

I did purge everything, even completely turned off caching but to no success. I am still getting the same error on older products, maybe I am doing something wrong here.
image

@mikejolley

This comment has been minimized.

Copy link
Member Author

commented Mar 4, 2019

@aliirshad9 I'll check tomorrow. Just to ask though, do any of those warnings actually show as errors on the search console thing? The fields you're being warned about should not be required, the docs state this.

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 4, 2019

@aliirshad9 I'll check tomorrow. Just to ask though, do any of those warnings actually show as errors on the search console thing? The fields you're being warned about should not be required, the docs state this.

@aliirshad9 I'll check tomorrow. Just to ask though, do any of those warnings actually show as errors on the search console thing? The fields you're being warned about should not be required, the docs state this.

Yes they do show as errors on search console, most of my products are de-listed or not being indexed by google, because of this. I am attaching the screenshot of google console, along with the error I am greeted with on console.
image
image

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 4, 2019

I have started the validation process, lets see if it gets sorted out in the morning, I'll keep you posted in either case if the case is resolved or not.

@kloon

kloon approved these changes Mar 5, 2019

@mikejolley mikejolley merged commit 2c2891c into master Mar 5, 2019

2 checks passed

Scrutinizer 3 new issues, 2 updated code elements
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@mikejolley mikejolley deleted the fix/22896 branch Mar 5, 2019

@JimmyRaz

This comment has been minimized.

Copy link

commented Mar 5, 2019

@mikejolley

When the current schema is asking for a field you need to provide it. That is your responsibility as the developer of an e-commerce platform.

I see the brand field is not listed in the cart itself with woocommerce. In order to fix this it will need to be listed. Most products have a brand. You do not want to have any of these errors. They will effect ranking.

Since you mentioned other platforms, I know for a fact that, some of them, list the brand field in the cart.

When we did our own schema, via html, we listed the brand field. You include all of the fields until you no longer have any errors or warnings. Both have a potential to effect ranking.

We also noticed that the review was demanded. To resolve this, on a new product, we did a review ( as ourselves ) . We stated there were no reviews for the product, did the review, and then offered customers a chance to give their opinions on it.

No more warning or errors.

It is very important to keep the cart up to date with the current schema.

@mikejolley

This comment has been minimized.

Copy link
Member Author

commented Mar 5, 2019

@JimmyRaz Thats not entirely true. Brand is not new FYI. It has been around since structured data was first introduced, and before that when schema.org took off.

I suggest you look over the docs here: https://developers.google.com/search/docs/guides/sd-policies

Don't mark up content that is not visible to readers of the page. For example, if the JSON-LD markup describes a performer, the HTML body should describe that same performer.

There is no need to markup or provide information that does not exist. Providing fake data is also against guidelines.

And: https://developers.google.com/search/docs/data-types/product

Brand is not a required property.

If you want to provide brand and any other field, extend the data (https://github.com/woocommerce/woocommerce/wiki/Structured-data-for-products) or use an extention that adds these properties.

@JimmyRaz

This comment has been minimized.

Copy link

commented Mar 5, 2019

@mikejolley

That is not what I suggested. I suggested you add the brand field to the cart. Mike I have been doing this for 20 years. I do not need to read any google documentation. I could certainly read some data on wordpress as this is new to us.

We did not include schema on our category pages when we did our own in html. Maybe you should have been a little more familiar with googles policies.

I suggested that you add the brand field to your shopping cart ( like most other carts do ) so if there is a brand the field can been filled.

Giving a review as yourself and stating yourself as the reviewer is not "Providing fake data".

We have never created a fake review in 20 years.

Can you please tell me where I ever suggested providing fake data???

You need to add the brand field as an option in woocommerce like most of the other platforms do. No fake data.

@mikejolley

This comment has been minimized.

Copy link
Member Author

commented Mar 5, 2019

@JimmyRaz We are not planning on adding brands to core.

Mike I have been doing this for 20 years. I do not need to read any google documentation

How is this relevant? Was google structured data around 20 years ago :)?

See the documentation here (https://developers.google.com/search/docs/data-types/product) and see Brand is a recommended property, not a required property.

If you really want to use brands, you can build it yourself and use the filters: https://github.com/woocommerce/woocommerce/wiki/Structured-data-for-products

Or use https://docs.woocommerce.com/document/wc-brands/

We do not need to add a field for brands to resolve the issue that was reported regarding errors in the console. The errors are resolved with this PR.

@JimmyRaz

This comment has been minimized.

Copy link

commented Mar 5, 2019

@mikejolley

You seem like a nice guy and I can see you are doing your best. But there is a reason it is recommended. If google is "recommending" the brand field then, like most of the other carts, you really should include it.

Why would you not? Are you protesting something?

I was not referring to schema. I know how long schema has been being utilized by google. I was referring to my experience with the behavior of search engines. For better for for worse that is now google.

Google is a program. You give it what it wants. No warnings, No errors. That is by far the best practice.

Thanks for the link to the link regarding filters. We will look into that.

@mikejolley

This comment has been minimized.

Copy link
Member Author

commented Mar 5, 2019

@JimmyRaz No I'm not protesting anything, it's just not possible to introduce a new "Brand" field into core right now because:

a) It has no place in a fix release, which this PR is intended for (3.5.6 to clear up the main errors)
b) there are business implications as it would overlap with a paid extension on the marketplace - this is not my call to make.
c) it would need proper design - it would be a new field after all. Should it be taxonomy? Meta? This is not a quick fix.

Core takes care of the required schema and a bunch more. There are solutions for brand that exist today which you can use right now.

@morris4ever69

This comment has been minimized.

Copy link

commented Mar 6, 2019

Is it safe to replace now this file in a production website to quick solve the errors (at least, the most part of the errors)?

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 7, 2019

Is it safe to replace now this file in a production website to quick solve the errors (at least, the most part of the errors)?

yes i have been using it for few days now. but i am not seeing any effect on old products? I am still confused why its not working.

@morris4ever69

This comment has been minimized.

Copy link

commented Mar 7, 2019

yes i have been using it for few days now. but i am not seeing any effect on old products? I am still confused why its not working.

I'm testing in local, I deleted all kind of cache, same behavior: some warning for old products. I hope in the next release they fix the problem for all the products.

@fdanell

This comment has been minimized.

Copy link

commented Mar 7, 2019

Have you found any workaround on how to make the old products working? Do I have to delete the entire shop`and create new ones?

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 7, 2019

Yeah I have been wondering the same woo commerce v3.5.6 is out but still the same issue on old products.

@mikejolley

This comment has been minimized.

Copy link
Member Author

commented Mar 7, 2019

I reckon there must be some kind of cache at play. All products have schema generated in the same way.

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 7, 2019

@mikejolley
Is this automatically implemented on all products? Sorry for the noob question. Or is there any way to regenerate it for older products. You have been great help so far. I have added new products and they seem to be doing exactly how you mentioned

@morris4ever69

This comment has been minimized.

Copy link

commented Mar 7, 2019

I confirm what written by mikejolley, there should be some kind of cache to clear. After updating WC to 3.5.6 and clearing the cache of WP Super Cache and Autoptimize, it works for all products.

I still have some warning in the test tool, like missing offerCount, brand (discussed about it at the top of the page) and a global identificator, but I suppose this is not related to WooCommerce itself.

P.S. I don't understand the meaning of the "offerCount" warning... I will try to lean more..

@fdanell

This comment has been minimized.

Copy link

commented Mar 7, 2019

hmm Some warnings passed validation. Was it something that needs to be done for my part to get rid of the "offers, review or aggregateRating" error, like, activating star-rating system or someting?

@JimmyRaz

This comment has been minimized.

Copy link

commented Mar 8, 2019

@mikejolley

We have installed the update and things seem to be working as described. Is there a reason you guys did not run the offerCount field into "stock quantity"?

Thanks for getting the update out.

@fdanell

This comment has been minimized.

Copy link

commented Mar 8, 2019

I'm using WP-Rocket, I've Flushed Cache and OPCache whatever that is. Also tried to disabling WP-Rocket. Are there any other standard wordpress caches that I might have missed? Are there any scenario in which the "offers, review or aggregateRating" error could start to show up in the latest WC? Maybe my products are misconfigured somehow.

@JimmyRaz

This comment has been minimized.

Copy link

commented Mar 9, 2019

@fdanell

I do not think they fixed offers. That field basically indicates how many of the items you are selling. If you "Enable stock management at product level" on the item page, you will be able to put that # in the "Stock quantity" field. We have done that and we are still getting the error.

Which leads me to believe they did not fix that in the latest update. I do not know why.

As far as the review and aggregate, that is fixed for every product we carry that has a review. The product must have a review or the warning will still show.

We are still getting - global identifier, brand, and offerCount warnings.

As far as the brand, it was stated that would not be addressed in the update.

@fdanell

This comment has been minimized.

Copy link

commented Mar 9, 2019

@JimmyRaz For me the "offers, review or aggregateRating" isn't a warning, it's an error.

@fdanell

This comment has been minimized.

Copy link

commented Mar 9, 2019

My products seem to have two objects that google fetch schema from. First from <script type="application/ld+json"> here I have only warnings, not errors. The other object is from <div id="product-7152" class="post-7152 product type-product ... itemtype="http://schema.org/Product"> this is where i'm getting the "offers, review or aggregateRating" error from.

@mikejolley

This comment has been minimized.

Copy link
Member Author

commented Mar 9, 2019

@fdanell that's markup from your theme.

@fdanell

This comment has been minimized.

Copy link

commented Mar 9, 2019

@mikejolley interresting, which one is theme? the <script> or the <div id="product-7152"

@mikejolley

This comment has been minimized.

Copy link
Member Author

commented Mar 9, 2019

WooCommerce inserts the JSON+LD script.

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 9, 2019

@fdanell @mikejolley the issue seems to be with product with no rating, as soon as a rating is post the error goes away. So the rating, is must in this case i reckon, or is there anyway to bypass this check.

@aliirshad9

This comment has been minimized.

Copy link

commented Mar 9, 2019

@fdanell @mikejolley I have tried rating different products for test basis and this issue has been resolved. Ask customers to leave ratings as they check out.

@fdanell

This comment has been minimized.

Copy link

commented Mar 9, 2019

@aliirshad9 My theme had this attribute added in the product div: "itemtype="http://schema.org/Product" which is not present in the default woocommerce product div. I omitted that and then I passed the initial validation check so fingers crossed. I'm not a developer by any means but it makes sense that this would cause problems becuse the rest of the div tree had no itemtype references at all so I guess that search console just thought, "here is an object but with no other information"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.