Using Yoast SEO Structured Data with Genesis

Yoast SEO includes an incredibly powerful implementation of structured data, which is a tool search engines use to better understand your website.

They have extensive documentation for extending it, and many plugins already integrate with it. For instance, if you are using WP Recipe Maker for recipes on your site, it will add the appropriate recipe schema to your Yoast SEO schema.

Genesis already includes structured data, also known as schema markup. You don’t want duplicate schema on the page, so you should use one or the other.

If you’re using Genesis 3.1 or later, Genesis’ schema will automatically disable if Yoast SEO schema is active. If you’re using Genesis 3.0 or earlier, you can install my Disable Genesis Schema plugin.

Here are some ways you might customize your schema:

Customization Options

Disable Genesis schema

Genesis will only disable its schema if Yoast SEO is active and Yoast schema is enabled.

If you’re using a different plugin to add schema data, you can disable Genesis schema by adding this to your child theme’s functions.php file:

add_filter( 'genesis_disable_microdata', '__return_true' );

Plugin developers: If your plugin is outputting schema data and you’d like Genesis to automatically disable its schema, you can use the filter genesis_is_wpseo_outputting_jsonld. Here’s the relevant function from /genesis/lib/functions/seo.php.

Disable Yoast SEO schema

If you would prefer keeping Genesis’ schema data, you can disable Yoast SEO’s schema data using the following code in your child theme’s functions.php file:

add_filter( 'wpseo_json_ld_output', '__return_false' );

This is a good option if you’ve already made customizations to the Genesis schema on your site and aren’t ready to rebuild that code to support Yoast’s structured data.

But if you’re like 99% of Genesis sites that haven’t modified the default schema, you’ll be better served switching over to Yoast SEO for schema data.

Use both Genesis and Yoast SEO schema

As described below in more detail, the Genesis schema describes more elements on the page than Yoast SEO.

Yoast focuses on only the schema search engines currently care about (the primary article on the page), while Genesis tries to describe all the elements on the page, like the Header, Navigation, Sidebar, Article, and Footer.

The code below will enable Genesis schema even when Yoast SEO is active, then selectively remove the Genesis schema that relates to the main article on the page.

I don’t believe there is any SEO benefit to this approach, but I’m asked how to do it often enough that I wanted to document it.

Add this code to your theme’s functions.php file:

// Tell Genesis that WP SEO is not outputting schema
add_filter( 'genesis_is_wpseo_outputting_jsonld', '__return_false' );

/**
 * Selectively Disable Genesis Schema elements
 * @author Bill Erickson
 * @see https://www.billerickson.net/yoast-schema-with-genesis/
 */
function be_selectively_disable_genesis_schema() {

	$elements = array(
		'entry',
		'entry-image',
		'entry-image-widget',
		'entry-image-grid-loop',
		'entry-author',
		'entry-author-link',
		'entry-author-name',
		'entry-time',
		'entry-modified-time',
		'entry-title',
		'entry-content',
	);

	foreach( $elements as $element ) {
		add_filter( 'genesis_attr_' . $element, 'be_remove_schema_attributes', 20 );
	}
}
add_action( 'init', 'be_selectively_disable_genesis_schema' );


/**
 * Remove schema attributes
 *
 */
function be_remove_schema_attributes( $attr ) {
	unset( $attr['itemprop'], $attr['itemtype'], $attr['itemscope'] );
	return $attr;
}

How Genesis Schema works

Genesis uses an approach called microdata, which are data attributes attached to elements already on the page to describe those elements to search engines. For instance, your post title has itemprop="headline" to tell search engines that this is the headline of the current article.

You can run into issues if you remove elements from the page because you’re also removing the schema data that’s attached to those elements. For instance, if you remove the author name from the top of the post, you also lose the structured data saying you’re the author of this post.

You also end up with many unconnected blocks of schema. Here’s the results of the Structured Data Testing Tool on an article on my site before the code change:

How Yoast SEO Schema works

Yoast SEO uses JSON-LD which is a newer and better approach to structured data (more information).

JSON is a lightweight method to structure data to share with search engines and others. Rather than scattering your Schema data throughout the page and making the search engine assemble it (e.g. microdata), you prepare a small block of code that tells search engines exactly what they need to know in one place.

The -LD part stands for Linked Data, which means you’re able to link all of the individual schema components together. In the screenshot above you can see everything is a separate block with microdata, but with JSON-LD it would follow a hierarchical structure. The Article is part of a WebPage which is part of a WebSite.

Here’s my structured data after disabling Genesis schema and using the latest version of Yoast SEO:

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments are closed. Continue the conversation with me on Twitter: @billerickson

Comments

  1. Hannah says

    Thank you so much for this Bill!
    Since I’m not familiar with PHP (I’m always so scared of adding stuff for fear of breaking up my pages), can you tell me where to add the code inside functions.php? At the very top or bottom? Thank you again!

    • Bill Erickson says

      If you’re not comfortable with writing PHP, I recommend installing my plugin instead. There’s no configuration or coding necessary.

  2. Miklos Mayer says

    Bill, thank you so much for this awesome work you do for the Genesis community!
    Really highly appreciate it!

    Installed your plugin, and it works just as you described, I’ve checked the schema data a minute after install, and it looked good 🙂

    Cheers from Hungary 🙂

  3. G'will Chijioke says

    Hi Bill, thanks for this post.

    I prefer putting the code in my theme and i just have one question.

    how do i use this code ” include_once( get_stylesheet_directory() . ‘/inc/disable-genesis-schema.php’ ); ” ?

    Do i just paste it in my functions.php file?

    • Bill Erickson says

      Yes, you put it in functions.php, assuming you added the disable-genesis-schema.php file into the /inc/ directory in your child theme. If you placed it elsewhere, update that path accordingly.

  4. Rajesh says

    Hello Bill,

    Thanks a lot for coming up with a quick solution.

    I want to ask one question: Yoast SEO is not adding WPHeader, WPSideBar, WPFooter, SiteNavigationElement, etc. What about that? Aren’t they important? Please let me know.

    Thanks once again.

    • Bill Erickson says

      I’m not a Schema / SEO expert, but my guess is Yoast didn’t include those items because they aren’t very important from an SEO perspective. The most important thing is providing structured data about the main content of the page, whether that be an article, recipe, event, or anything else.

      That said, I don’t think you would have any issues including all the non-article-related schema since it doesn’t duplicate anything found in Yoast SEO. I made the plugin filterable so you can decide exactly which schema items get removed and which remain.

      If you would like to keep the WPHeader, WPSideBar, WPFooter, and SiteNavigationElement, add this to your theme’s functions.php file: https://gist.github.com/billerickson/e7434b8ae761f452831ecd7eeb79c963

      I’ve updated the post above to include a note about saving some schema.

  5. Cathy Tibbles says

    Thank you so much for sharing this code! I’m wondering about why you removed some elements with a second function instead of just removing them from be_disable_genesis_schema()? Is this a long-term use kinda thing? I like to follow your logic with these things. And thank you SO much for teaching us the proper way to do them!

    We started using core plugins because of your tutorials years ago. Thank you!!

    • Bill Erickson says

      If you have the plugin installed, it’s best to make your customizations using the filter in your theme or core functionality plugin so they aren’t lost if the plugin is updated.

      • Cathy Tibbles says

        I’m using the code in a core plugin. So I just commented out the elements I don’t want removed from Genesis. Is there a reason to do it with another function?

  6. Monica says

    I downloaded the plugin twice and it’s not working for me.

    It still says Warning: Illegal string offset ‘width’ in /home/mindfull/public_html/wp-content/plugins/wordpress-seo/frontend/schema/class-schema-image.php on line 149

    Warning: Illegal string offset ‘height’ in /home/mindfull/public_html/wp-content/plugins/wordpress-seo/frontend/schema/class-schema-image.php on line 150

    It says just download and activate. But do I need to do anything else?

  7. Mary Ann says

    This was recommended to me by my tech support so I added the plugin and it disabled Genesis. Now my traffic and affiliate sales are declining over the past two weeks. Coincidence? I’ve heard others say the same thing. Bill do you have any insight here? Thanks.

    • Bill Erickson says

      This plugin is designed to disable the Genesis schema data, and should only be used if you have Yoast SEO installed as well. Yoast now includes schema, and this plugin ensures you don’t load duplicate schema.

      I can’t provide any insight on your declining traffic. If you think it may be related to removing Genesis schema, I recommend you contact your tech support and ask them to disable Yoast schema instead of using this plugin. That will restore your site back to how it was prior to Yoast SEO 11 being released with schema.

  8. Dedra says

    Genesis just released a 2.10.0 update to their themes along with Yoasts 11.1 update. I updated Yoast but I’m nervous to update Genesis. Is it safe to update while I have this plugin installed, or at all for that matter? A few people have said they’ve been experiencing problems with the new update but I’d like to know your opinion.

    • Bill Erickson says

      My plugin is safe to use with all versions of Genesis, including the newly released 2.10. The new version of Genesis does not address the Yoast schema issue in any way, and the official recommendation from StudioPress is to install my plugin for now.

      There was an issue in Genesis 2.10 on sites using old versions of WordPress (4.9.10). If you aren’t using WordPress 5.0 or 5.1 yet, I recommend holding off on updating Genesis. Genesis 2.10.1 should fix this bug in the next day or two.