wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

Add schema.org markup

Open iagdotme opened this issue 13 years ago • 16 comments

On a per post basis: Choice of document type (dropdown menu): eg AboutPage, CheckoutPage, CollectionPage, ContactPage, ItemPage, MedicalWebPage, ProfilePage, SearchResultsPage (also ability to set default for all posts/pages/categories etc). This might be difficult to implement since it would involve adding to the tag.

iagdotme avatar Aug 20 '13 09:08 iagdotme

Actually very easy to do for Genesis based sites :)

jdevalk avatar Aug 20 '13 09:08 jdevalk

I am sure it is, I haven't used Genesis. I custom build my sites using Roots Theme. I suppose I could create my own function to add this feature to my theme, but I wondered whether this might be a useful feature for WordPress SEO? Or do you think this would best offered from a theme such as Genesis or a custom function?

iagdotme avatar Aug 20 '13 10:08 iagdotme

I know this doesn't help your specific use case, but there already is a solution for Genesis.

remkus avatar Aug 20 '13 10:08 remkus

@defries thanks, if you know of a solution that isn't just for Genesis I am all ears. I would rather avoid a plugin, but that is only because I am a complete control freak! ;-)

It sounds like the opinion so far is that this is best done by the theme. However, for less techie people it would be good if there was a solution baked into WordPress SEO or an addon that offered this. schema.org apparently is the future...

iagdotme avatar Aug 20 '13 10:08 iagdotme

@yoast I should have clarified a little further, there are other things you can do to add schema markup to the head in addition to the title tag which WordPress SEO could add. For example the canonical link and meta description tags.

There is an interesting article by Felix Arntz with a function that modifies these tags using the WPSEO_Frontend class:

<?php 
function yourtheme_meta_schema()
{
    if( class_exists( 'WPSEO_Frontend' ) )
    {
        global $wpseo_front;

        $canonical = $wpseo_front->canonical( false );
        echo '<link itemprop="url" href="' . esc_url( $canonical, null, 'other' ) . '" />' . "\n";
        $metadesc = $wpseo_front->metadesc( false );
        echo '<meta itemprop="description" content="' . esc_attr( strip_tags( stripslashes( $metadesc ) ) ) . '" />' . "\n";
    }
}
add_action( 'wp_head', 'yourtheme_meta_schema' );
?>

Wondering if this kind of functionality could be baked in?

iagdotme avatar Aug 20 '13 10:08 iagdotme

And of course it would be good if breadcrumbs used microdata - https://support.google.com/webmasters/answer/185417?hl=en

iagdotme avatar Aug 20 '13 10:08 iagdotme

Breadcrumbs already use RDFA, as that's Google's preferred method. As for canonical and meta description: the plugin already does those, but doesn't use the itemprop attribute...

jdevalk avatar Aug 20 '13 11:08 jdevalk

@Yoast I had assumed Google preferred schema for everything. Strange they prefer RDFa for breadcrumbs and microdata for everything else. I'd be interested in where they state this. Would it be possible for the plugin to add the itemprop attribute to the canonical and meta description?

iagdotme avatar Aug 20 '13 12:08 iagdotme

Hello everyone, in my opinion Schema.org goes pretty much into WordPress themes, so I don't think it would be really coherent using only a plugin.

@Yoast I would prefer a way to access all the meta information from your SEO plugin from outside. Your class methods 'canonical' and 'metadesc' allow to only return the content instead of echoing it - so why not do this for all meta information? This way one could easily add the necessary Schema.org attributes in there when outputting the content manually.

felixarntz avatar Aug 21 '13 09:08 felixarntz

@Yoast I just wrote a class that modifies the breadcrumbs from your plugin to use Schema.org markup instead of RDFa. I just did it exactly the way 'data-vocabulary.org' tells you to use it, but instead used 'schema.org' links - this seems to work fine for Google, at least it did in a few tests. I embedded the class in this short article - http://leaves-and-love.net/how-to-modify-wp-seo-breadcrumbs-for-schema-org/

This might be useful for someone who wants his theme to use Schema.org, but take meta information, breadcrumbs and such from the WordPress SEO plugin.

felixarntz avatar Aug 21 '13 13:08 felixarntz

Google itself still states it prefers RDFa for breadcrumbs, simply because the schema markup for it isn't exactly specific and rather hard to parse for them, see this:

http://lists.w3.org/Archives/Public/public-rdfa-wg/2012Nov/0027.html

jdevalk avatar Aug 21 '13 13:08 jdevalk

But what exactly in this email tells you that RDFa is preferred over Schema.org? I don't understand everything in the mail, so it would be nice if you could illuminate me on that a bit.

Google generally recommends using Schema.org, and it works for breadcrumbs aswell. Maybe this is just my personal opinion, but I think it would be more coherent to use Schema.org for everything. Of course that would be different if there were errors or if it could not be recognized by Google, but that isn't the case.

felixarntz avatar Sep 13 '13 11:09 felixarntz

Any news for this feature?

Mte90 avatar Nov 11 '13 09:11 Mte90

Hi, last time we checked this on the rich snippet tester from Google, is that breadcrumbs based on schema.org are not working! That Yoast is using rDFA is the right choise, because that is working.

Willem-Siebe avatar Feb 27 '14 15:02 Willem-Siebe

So, as long as Google themselves recommend using rDFA over Schema, and they have repeatedly done so in the above thread and elsewhere as well as in private email, we're sticking with that. Closing this issue for now.

jdevalk avatar Mar 05 '14 08:03 jdevalk

I've got a variable product with 4 different prices. I've managed to markup each product in a way google gives me a nice price range snippet from the lowest to the highest...

e.g

img_0056

It turns out if I use WordPress SEO breadcrumb rDFA markup, that nice price range snippet is gone.

I've performed a few tests, and it seems that If I remove the rDFA breadcrumbs the snippet comes back.

There's no such issue though marking up a custom breadcrumb with https://schema.org/BreadcrumbList

Weird I know, but I had to drop rdfa in favor of the schema markup in order to get the snippets to show the way I wanted them to be.

monecchi avatar Feb 06 '17 14:02 monecchi